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

PageReloadOverlay.native.js 3.1KB

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