jiti-meet/react/features/overlay/components/native/PageReloadOverlay.js

96 lines
2.6 KiB
JavaScript
Raw Normal View History

2019-03-06 16:28:59 +00:00
// @flow
import React from 'react';
import { appNavigate, reloadNow } from '../../../app/actions';
2019-04-09 11:05:20 +00:00
import { ConfirmDialog } from '../../../base/dialog';
import { translate } from '../../../base/i18n';
import { connect } from '../../../base/redux';
import { setFatalError, setPageReloadOverlayCanceled } from '../../actions';
2019-03-06 16:28:59 +00:00
import AbstractPageReloadOverlay, {
type Props,
abstractMapStateToProps
2019-04-09 11:05:20 +00:00
} from '../AbstractPageReloadOverlay';
import OverlayFrame from './OverlayFrame';
2019-03-06 16:28:59 +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;
/**
* 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);
}
2021-11-04 21:10:43 +00:00
_onCancel: () => void;
2019-03-06 16:28:59 +00:00
/**
* Handle clicking of the "Cancel" button. It will navigate back to the
* welcome page.
*
* @private
* @returns {void}
*/
_onCancel() {
clearInterval(this._interval);
this.props.dispatch(setPageReloadOverlayCanceled(this.props.error));
this.props.dispatch(setFatalError(undefined));
this.props.dispatch(appNavigate(undefined));
}
2021-11-04 21:10:43 +00:00
_onReloadNow: () => void;
2019-03-06 16:28:59 +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);
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 (
<OverlayFrame>
2019-03-06 16:28:59 +00:00
<ConfirmDialog
cancelLabel = 'dialog.Cancel'
confirmLabel = 'dialog.rejoinNow'
descriptionKey = { `${t(message, { seconds: timeLeft })}` }
2019-03-06 16:28:59 +00:00
onCancel = { this._onCancel }
onSubmit = { this._onReloadNow }
title = { title } />
</OverlayFrame>
);
}
}
export default translate(connect(abstractMapStateToProps)(PageReloadOverlay));