2019-03-06 16:28:59 +00:00
|
|
|
// @flow
|
|
|
|
|
2017-11-24 15:23:40 +00:00
|
|
|
import React from 'react';
|
2019-03-06 16:28:59 +00:00
|
|
|
import { Text } from 'react-native';
|
2017-11-24 15:23:40 +00:00
|
|
|
|
2019-04-09 11:05:20 +00:00
|
|
|
import { appNavigate, reloadNow } from '../../../app';
|
|
|
|
import { ColorSchemeRegistry } from '../../../base/color-scheme';
|
|
|
|
import { ConfirmDialog } from '../../../base/dialog';
|
|
|
|
import { translate } from '../../../base/i18n';
|
|
|
|
import { connect } from '../../../base/redux';
|
|
|
|
import { StyleType } from '../../../base/styles';
|
|
|
|
import { setFatalError } from '../../actions';
|
2019-03-06 16:28:59 +00:00
|
|
|
import AbstractPageReloadOverlay, {
|
|
|
|
abstractMapStateToProps,
|
|
|
|
type Props as AbstractProps
|
2019-04-09 11:05:20 +00:00
|
|
|
} from '../AbstractPageReloadOverlay';
|
|
|
|
|
2017-11-24 15:23:40 +00:00
|
|
|
import OverlayFrame from './OverlayFrame';
|
2019-03-06 16:28:59 +00:00
|
|
|
|
|
|
|
type Props = AbstractProps & {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The color-schemed stylesheet of the base/dialog feature.
|
|
|
|
*/
|
|
|
|
_dialogStyles: StyleType
|
|
|
|
}
|
2017-11-24 15:23:40 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements a React Component for page reload overlay. Shown before the
|
|
|
|
* conference is reloaded. Shows a warning message and counts down towards the
|
|
|
|
* reload.
|
|
|
|
*/
|
2019-03-06 16:28:59 +00:00
|
|
|
class PageReloadOverlay extends AbstractPageReloadOverlay<Props> {
|
|
|
|
_interval: IntervalID;
|
|
|
|
|
2017-11-24 15:23:40 +00:00
|
|
|
/**
|
|
|
|
* 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);
|
|
|
|
}
|
|
|
|
|
2019-03-06 16:28:59 +00:00
|
|
|
_onCancel: () => void
|
|
|
|
|
2017-11-24 15:23:40 +00:00
|
|
|
/**
|
|
|
|
* Handle clicking of the "Cancel" button. It will navigate back to the
|
|
|
|
* welcome page.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_onCancel() {
|
|
|
|
clearInterval(this._interval);
|
2018-06-26 12:18:29 +00:00
|
|
|
this.props.dispatch(setFatalError(undefined));
|
2017-11-24 15:23:40 +00:00
|
|
|
this.props.dispatch(appNavigate(undefined));
|
|
|
|
}
|
|
|
|
|
2019-03-06 16:28:59 +00:00
|
|
|
_onReloadNow: () => void
|
|
|
|
|
2017-11-24 15:23:40 +00:00
|
|
|
/**
|
|
|
|
* 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);
|
2018-07-02 21:22:51 +00:00
|
|
|
this.props.dispatch(reloadNow());
|
2017-11-24 15:23:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements React's {@link Component#render()}.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
|
|
|
render() {
|
2019-03-06 16:28:59 +00:00
|
|
|
const { _dialogStyles, t } = this.props;
|
2017-11-24 15:23:40 +00:00
|
|
|
const { message, timeLeft, title } = this.state;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<OverlayFrame>
|
2019-03-06 16:28:59 +00:00
|
|
|
<ConfirmDialog
|
|
|
|
cancelKey = 'dialog.Cancel'
|
|
|
|
okKey = 'dialog.rejoinNow'
|
|
|
|
onCancel = { this._onCancel }
|
|
|
|
onSubmit = { this._onReloadNow }>
|
|
|
|
<Text style = { _dialogStyles.text }>
|
|
|
|
{ `${t(title)} ${t(message, { seconds: timeLeft })}` }
|
2017-11-24 15:23:40 +00:00
|
|
|
</Text>
|
2019-03-06 16:28:59 +00:00
|
|
|
</ConfirmDialog>
|
2017-11-24 15:23:40 +00:00
|
|
|
</OverlayFrame>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-06 16:28:59 +00:00
|
|
|
/**
|
|
|
|
* Maps part of the Redux state to the props of this component.
|
|
|
|
*
|
|
|
|
* @param {Object} state - The Redux state.
|
|
|
|
* @returns {{
|
|
|
|
* _dialogStyles: StyleType
|
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
function _mapStateToProps(state) {
|
|
|
|
return {
|
|
|
|
...abstractMapStateToProps(state),
|
|
|
|
_dialogStyles: ColorSchemeRegistry.get(state, 'Dialog')
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export default translate(connect(_mapStateToProps)(PageReloadOverlay));
|