您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

PageReloadOverlay.js 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. // @flow
  2. import React from 'react';
  3. import { Text } from 'react-native';
  4. import { appNavigate, reloadNow } from '../../../app/actions';
  5. import { ColorSchemeRegistry } from '../../../base/color-scheme';
  6. import { ConfirmDialog } from '../../../base/dialog';
  7. import { translate } from '../../../base/i18n';
  8. import { connect } from '../../../base/redux';
  9. import { StyleType } from '../../../base/styles';
  10. import { setFatalError } from '../../actions';
  11. import AbstractPageReloadOverlay, {
  12. abstractMapStateToProps,
  13. type Props as AbstractProps
  14. } from '../AbstractPageReloadOverlay';
  15. import OverlayFrame from './OverlayFrame';
  16. type Props = AbstractProps & {
  17. /**
  18. * The color-schemed stylesheet of the base/dialog feature.
  19. */
  20. _dialogStyles: StyleType
  21. }
  22. /**
  23. * Implements a React Component for page reload overlay. Shown before the
  24. * conference is reloaded. Shows a warning message and counts down towards the
  25. * reload.
  26. */
  27. class PageReloadOverlay extends AbstractPageReloadOverlay<Props> {
  28. _interval: IntervalID;
  29. /**
  30. * Initializes a new PageReloadOverlay instance.
  31. *
  32. * @param {Object} props - The read-only properties with which the new
  33. * instance is to be initialized.
  34. * @public
  35. */
  36. constructor(props) {
  37. super(props);
  38. this._onCancel = this._onCancel.bind(this);
  39. this._onReloadNow = this._onReloadNow.bind(this);
  40. }
  41. _onCancel: () => void
  42. /**
  43. * Handle clicking of the "Cancel" button. It will navigate back to the
  44. * welcome page.
  45. *
  46. * @private
  47. * @returns {void}
  48. */
  49. _onCancel() {
  50. clearInterval(this._interval);
  51. this.props.dispatch(setFatalError(undefined));
  52. this.props.dispatch(appNavigate(undefined));
  53. }
  54. _onReloadNow: () => void
  55. /**
  56. * Handle clicking on the "Reload Now" button. It will navigate to the same
  57. * conference URL as before immediately, without waiting for the timer to
  58. * kick in.
  59. *
  60. * @private
  61. * @returns {void}
  62. */
  63. _onReloadNow() {
  64. clearInterval(this._interval);
  65. this.props.dispatch(reloadNow());
  66. }
  67. /**
  68. * Implements React's {@link Component#render()}.
  69. *
  70. * @inheritdoc
  71. * @returns {ReactElement}
  72. */
  73. render() {
  74. const { _dialogStyles, t } = this.props;
  75. const { message, timeLeft, title } = this.state;
  76. return (
  77. <OverlayFrame>
  78. <ConfirmDialog
  79. cancelKey = 'dialog.Cancel'
  80. okKey = 'dialog.rejoinNow'
  81. onCancel = { this._onCancel }
  82. onSubmit = { this._onReloadNow }>
  83. <Text style = { _dialogStyles.text }>
  84. { `${t(title)} ${t(message, { seconds: timeLeft })}` }
  85. </Text>
  86. </ConfirmDialog>
  87. </OverlayFrame>
  88. );
  89. }
  90. }
  91. /**
  92. * Maps part of the Redux state to the props of this component.
  93. *
  94. * @param {Object} state - The Redux state.
  95. * @returns {{
  96. * _dialogStyles: StyleType
  97. * }}
  98. */
  99. function _mapStateToProps(state) {
  100. return {
  101. ...abstractMapStateToProps(state),
  102. _dialogStyles: ColorSchemeRegistry.get(state, 'Dialog')
  103. };
  104. }
  105. export default translate(connect(_mapStateToProps)(PageReloadOverlay));