import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { defineMessages, injectIntl } from 'react-intl'; import { notify } from '/imports/ui/services/notification'; import { getSettingsSingletonInstance } from '/imports/ui/services/settings'; import Styled from './styles'; const intlMessages = defineMessages({ wakeLockOfferTitle: { id: 'app.toast.wakeLock.offerTitle', }, wakeLockAcquireSuccess: { id: 'app.toast.wakeLock.acquireSuccess', }, wakeLockAcquireFailed: { id: 'app.toast.wakeLock.acquireFailed', }, wakeLockNotSupported: { id: 'app.toast.wakeLock.notSupported', }, wakeLockDisclaimer: { id: 'app.toast.wakeLock.disclaimer', } }); const propTypes = { intl: PropTypes.objectOf(Object).isRequired, request: PropTypes.func.isRequired, release: PropTypes.func.isRequired, wakeLockSettings: PropTypes.bool.isRequired, setLocalSettings: PropTypes.func.isRequired, }; class WakeLock extends Component { constructor() { super(); } componentDidMount() { const { wakeLockSettings } = this.props; if (wakeLockSettings) { this.requestWakeLock(); } } componentDidUpdate(prevProps) { const { wakeLockSettings, release } = this.props; if (wakeLockSettings !== prevProps.wakeLockSettings) { if (wakeLockSettings) { this.requestWakeLock(); } else { release(); } } } getToast(id, message) { return (