import React from 'react'; import { Text, View } from 'react-native'; import { connect } from 'react-redux'; import { appNavigate } from '../../app'; import { translate } from '../../base/i18n'; import { LoadingIndicator } from '../../base/react'; import AbstractPageReloadOverlay, { abstractMapStateToProps } from './AbstractPageReloadOverlay'; import { _reloadNow, setFatalError } from '../actions'; import OverlayFrame from './OverlayFrame'; import { pageReloadOverlay as styles } from './styles'; /** * Implements a React Component for page reload overlay. Shown before the * conference is reloaded. Shows a warning message and counts down towards the * reload. */ class PageReloadOverlay extends AbstractPageReloadOverlay { /** * Initializes a new PageReloadOverlay instance. * * @param {Object} props - The read-only properties with which the new * instance is to be initialized. * @public */ constructor(props) { super(props); this._onCancel = this._onCancel.bind(this); this._onReloadNow = this._onReloadNow.bind(this); } /** * Handle clicking of the "Cancel" button. It will navigate back to the * welcome page. * * @private * @returns {void} */ _onCancel() { clearInterval(this._interval); this.props.dispatch(setFatalError(undefined)); this.props.dispatch(appNavigate(undefined)); } /** * Handle clicking on the "Reload Now" button. It will navigate to the same * conference URL as before immediately, without waiting for the timer to * kick in. * * @private * @returns {void} */ _onReloadNow() { clearInterval(this._interval); this.props.dispatch(_reloadNow()); } /** * Implements React's {@link Component#render()}. * * @inheritdoc * @returns {ReactElement} */ render() { const { t } = this.props; const { message, timeLeft, title } = this.state; return ( { t(title) } { t(message, { seconds: timeLeft }) } { t('dialog.rejoinNow') } { t('dialog.Cancel') } ); } } export default translate(connect(abstractMapStateToProps)(PageReloadOverlay));