選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

OverlayContainer.js 8.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. import React, { Component } from 'react';
  2. import { connect } from 'react-redux';
  3. import { CallOverlay } from '../../jwt';
  4. import PageReloadFilmstripOnlyOverlay from './PageReloadFilmstripOnlyOverlay';
  5. import PageReloadOverlay from './PageReloadOverlay';
  6. import SuspendedFilmstripOnlyOverlay from './SuspendedFilmstripOnlyOverlay';
  7. import SuspendedOverlay from './SuspendedOverlay';
  8. import UserMediaPermissionsFilmstripOnlyOverlay
  9. from './UserMediaPermissionsFilmstripOnlyOverlay';
  10. import UserMediaPermissionsOverlay from './UserMediaPermissionsOverlay';
  11. declare var APP: Object;
  12. declare var interfaceConfig: Object;
  13. /**
  14. * Implements a React Component that will display the correct overlay when
  15. * needed.
  16. */
  17. class OverlayContainer extends Component {
  18. /**
  19. * OverlayContainer component's property types.
  20. *
  21. * @static
  22. */
  23. static propTypes = {
  24. /**
  25. * The browser which is used currently.
  26. *
  27. * NOTE: Used by UserMediaPermissionsOverlay only.
  28. *
  29. * @private
  30. * @type {string}
  31. */
  32. _browser: React.PropTypes.string,
  33. /**
  34. * The indicator which determines whether the {@link CallOverlay} is
  35. * displayed/visible.
  36. *
  37. * @private
  38. * @type {boolean}
  39. */
  40. _callOverlayVisible: React.PropTypes.bool,
  41. /**
  42. * The indicator which determines whether the status of the
  43. * JitsiConnection object has been "established" or not.
  44. *
  45. * NOTE: Used by PageReloadOverlay only.
  46. *
  47. * @private
  48. * @type {boolean}
  49. */
  50. _connectionEstablished: React.PropTypes.bool,
  51. /**
  52. * The indicator which determines whether a critical error for reload
  53. * has been received.
  54. *
  55. * NOTE: Used by PageReloadOverlay only.
  56. *
  57. * @private
  58. * @type {boolean}
  59. */
  60. _haveToReload: React.PropTypes.bool,
  61. /**
  62. * The indicator which determines whether the GUM permissions prompt is
  63. * displayed or not.
  64. *
  65. * NOTE: Used by UserMediaPermissionsOverlay only.
  66. *
  67. * @private
  68. * @type {boolean}
  69. */
  70. _isMediaPermissionPromptVisible: React.PropTypes.bool,
  71. /**
  72. * The indicator which determines whether the reload was caused by
  73. * network failure.
  74. *
  75. * NOTE: Used by PageReloadOverlay only.
  76. *
  77. * @private
  78. * @type {boolean}
  79. */
  80. _isNetworkFailure: React.PropTypes.bool,
  81. /**
  82. * The reason for the error that will cause the reload.
  83. *
  84. * NOTE: Used by PageReloadOverlay only.
  85. *
  86. * @private
  87. * @type {string}
  88. */
  89. _reason: React.PropTypes.string,
  90. /**
  91. * The indicator which determines whether the GUM permissions prompt is
  92. * displayed or not.
  93. *
  94. * NOTE: Used by SuspendedOverlay only.
  95. *
  96. * @private
  97. * @type {string}
  98. */
  99. _suspendDetected: React.PropTypes.bool
  100. };
  101. /**
  102. * Initializes a new ReloadTimer instance.
  103. *
  104. * @param {Object} props - The read-only properties with which the new
  105. * instance is to be initialized.
  106. * @public
  107. */
  108. constructor(props) {
  109. super(props);
  110. this.state = {
  111. /**
  112. * The indicator which determines whether filmstrip-only mode is
  113. * enabled.
  114. *
  115. * @type {boolean}
  116. */
  117. filmstripOnly:
  118. typeof interfaceConfig === 'object'
  119. && interfaceConfig.filmStripOnly
  120. };
  121. }
  122. /**
  123. * React Component method that executes once component is updated.
  124. *
  125. * @inheritdoc
  126. * @returns {void}
  127. * @protected
  128. */
  129. componentDidUpdate() {
  130. if (typeof APP === 'object') {
  131. APP.UI.overlayVisible
  132. = (this.props._connectionEstablished
  133. && this.props._haveToReload)
  134. || this.props._suspendDetected
  135. || this.props._isMediaPermissionPromptVisible;
  136. }
  137. }
  138. /**
  139. * Implements React's {@link Component#render()}.
  140. *
  141. * @inheritdoc
  142. * @returns {ReactElement|null}
  143. * @public
  144. */
  145. render() {
  146. const { filmstripOnly } = this.state;
  147. let overlayComponent, props;
  148. if (this.props._connectionEstablished && this.props._haveToReload) {
  149. overlayComponent
  150. = filmstripOnly
  151. ? PageReloadFilmstripOnlyOverlay
  152. : PageReloadOverlay;
  153. props = {
  154. isNetworkFailure: this.props._isNetworkFailure,
  155. reason: this.props._reason
  156. };
  157. } else if (this.props._suspendDetected) {
  158. overlayComponent
  159. = filmstripOnly
  160. ? SuspendedFilmstripOnlyOverlay
  161. : SuspendedOverlay;
  162. } else if (this.props._isMediaPermissionPromptVisible) {
  163. overlayComponent
  164. = filmstripOnly
  165. ? UserMediaPermissionsFilmstripOnlyOverlay
  166. : UserMediaPermissionsOverlay;
  167. props = {
  168. browser: this.props._browser
  169. };
  170. } else if (this.props._callOverlayVisible) {
  171. overlayComponent = CallOverlay;
  172. }
  173. return (
  174. overlayComponent
  175. ? React.createElement(overlayComponent, props)
  176. : null);
  177. }
  178. }
  179. /**
  180. * Maps (parts of) the redux state to the associated OverlayContainer's props.
  181. *
  182. * @param {Object} state - The redux state.
  183. * @returns {{
  184. * _browser: string,
  185. * _callOverlayVisible: boolean,
  186. * _connectionEstablished: boolean,
  187. * _haveToReload: boolean,
  188. * _isNetworkFailure: boolean,
  189. * _isMediaPermissionPromptVisible: boolean,
  190. * _reason: string,
  191. * _suspendDetected: boolean
  192. * }}
  193. * @private
  194. */
  195. function _mapStateToProps(state) {
  196. const stateFeaturesOverlay = state['features/overlay'];
  197. return {
  198. /**
  199. * The browser which is used currently.
  200. *
  201. * NOTE: Used by {@link UserMediaPermissionsOverlay} only.
  202. *
  203. * @private
  204. * @type {string}
  205. */
  206. _browser: stateFeaturesOverlay.browser,
  207. /**
  208. * The indicator which determines whether the {@link CallOverlay} is
  209. * displayed/visible.
  210. *
  211. * @private
  212. * @type {boolean}
  213. */
  214. _callOverlayVisible: Boolean(state['features/jwt'].callOverlayVisible),
  215. /**
  216. * The indicator which determines whether the status of the
  217. * JitsiConnection object has been "established" or not.
  218. *
  219. * NOTE: Used by {@link PageReloadOverlay} only.
  220. *
  221. * @private
  222. * @type {boolean}
  223. */
  224. _connectionEstablished: stateFeaturesOverlay.connectionEstablished,
  225. /**
  226. * The indicator which determines whether a critical error for reload
  227. * has been received.
  228. *
  229. * NOTE: Used by {@link PageReloadOverlay} only.
  230. *
  231. * @private
  232. * @type {boolean}
  233. */
  234. _haveToReload: stateFeaturesOverlay.haveToReload,
  235. /**
  236. * The indicator which determines whether the GUM permissions prompt is
  237. * displayed or not.
  238. *
  239. * NOTE: Used by {@link UserMediaPermissionsOverlay} only.
  240. *
  241. * @private
  242. * @type {boolean}
  243. */
  244. _isMediaPermissionPromptVisible:
  245. stateFeaturesOverlay.isMediaPermissionPromptVisible,
  246. /**
  247. * The indicator which determines whether the reload was caused by
  248. * network failure.
  249. *
  250. * NOTE: Used by {@link PageReloadOverlay} only.
  251. *
  252. * @private
  253. * @type {boolean}
  254. */
  255. _isNetworkFailure: stateFeaturesOverlay.isNetworkFailure,
  256. /**
  257. * The reason for the error that will cause the reload.
  258. *
  259. * NOTE: Used by {@link PageReloadOverlay} only.
  260. *
  261. * @private
  262. * @type {string}
  263. */
  264. _reason: stateFeaturesOverlay.reason,
  265. /**
  266. * The indicator which determines whether the GUM permissions prompt is
  267. * displayed or not.
  268. *
  269. * NOTE: Used by {@link SuspendedOverlay} only.
  270. *
  271. * @private
  272. * @type {string}
  273. */
  274. _suspendDetected: stateFeaturesOverlay.suspendDetected
  275. };
  276. }
  277. export default connect(_mapStateToProps)(OverlayContainer);