Просмотр исходного кода

Move ConferenceUrl.reload into React and redux

master
Lyubo Marinov 8 лет назад
Родитель
Сommit
e2afb4c7e7

+ 1
- 34
modules/URL/ConferenceUrl.js Просмотреть файл

@@ -1,7 +1,5 @@
1 1
 const logger = require("jitsi-meet-logger").getLogger(__filename);
2 2
 
3
-import { reload, replace } from '../util/helpers';
4
-
5 3
 /**
6 4
  * The modules stores information about the URL used to start the conference and
7 5
  * provides utility methods for dealing with conference URL and reloads.
@@ -18,24 +16,14 @@ export default class ConferenceUrl {
18 16
      *
19 17
      * @param location.href full URL with all parameters, would be the whole URL
20 18
      * from the example string above.
21
-     *
22 19
      * @param location.host the host part of the URL, 'example.com' from
23 20
      * the sample URL above.
24
-     *
25 21
      * @param location.pathname the path part of the URL, would be
26 22
      * '/SomeConference1245' from the example above.
27
-     *
28 23
      * @param location.protocol the protocol part of the URL, would be 'https:'
29 24
      * from the sample URL.
30 25
      */
31 26
     constructor(location) {
32
-        /**
33
-         * Stores the original conference room URL with all parameters.
34
-         * Example:
35
-         * https://example.com:8888/SomeConference1245?jwt=a5sbc2#blablahash
36
-         * @type {string}
37
-         */
38
-        this.originalURL = location.href;
39 27
         /**
40 28
          * A simplified version of the conference URL stripped out of
41 29
          * the parameters which should be used for sending invites.
@@ -45,7 +33,7 @@ export default class ConferenceUrl {
45 33
          */
46 34
         this.inviteURL
47 35
             = location.protocol + "//" + location.host + location.pathname;
48
-        logger.info("Stored original conference URL: " + this.originalURL);
36
+        logger.info("Stored original conference URL: " + location.href);
49 37
         logger.info("Conference URL for invites: " + this.inviteURL);
50 38
     }
51 39
     /**
@@ -56,25 +44,4 @@ export default class ConferenceUrl {
56 44
     getInviteUrl() {
57 45
         return this.inviteURL;
58 46
     }
59
-    /**
60
-     * Obtains full conference URL with all original parameters.
61
-     * @return {string} the original URL used to open the current conference.
62
-     */
63
-    getOriginalUrl() {
64
-        return this.originalURL;
65
-    }
66
-    /**
67
-     * Reloads the conference using original URL with all of the parameters.
68
-     */
69
-    reload() {
70
-        logger.info(`Reloading the conference using URL: ${this.originalURL}`);
71
-
72
-        // Check if we are in an iframe and reload with the reload() utility
73
-        // because replace() is not working on an iframe.
74
-        if(window.self !== window.top) {
75
-            reload();
76
-        } else {
77
-            replace(this.originalURL);
78
-        }
79
-    }
80 47
 }

+ 26
- 0
react/features/overlay/actions.js Просмотреть файл

@@ -1,8 +1,12 @@
1
+import { reload, replace } from '../../../modules/util/helpers';
2
+
1 3
 import {
2 4
     MEDIA_PERMISSION_PROMPT_VISIBILITY_CHANGED,
3 5
     SUSPEND_DETECTED
4 6
 } from './actionTypes';
5 7
 
8
+const logger = require('jitsi-meet-logger').getLogger(__filename);
9
+
6 10
 /**
7 11
  * Signals that the prompt for media permission is visible or not.
8 12
  *
@@ -24,6 +28,28 @@ export function mediaPermissionPromptVisibilityChanged(isVisible, browser) {
24 28
     };
25 29
 }
26 30
 
31
+/**
32
+ * Reloads the page.
33
+ *
34
+ * @protected
35
+ * @returns {Function}
36
+ */
37
+export function _reloadNow() {
38
+    return (dispatch, getState) => {
39
+        const { locationURL } = getState()['features/base/connection'];
40
+
41
+        logger.info(`Reloading the conference using URL: ${locationURL}`);
42
+
43
+        // In an iframe reload with the reload() utility because the replace()
44
+        // utility does not work on an iframe.
45
+        if (window.self === window.top) {
46
+            replace(locationURL);
47
+        } else {
48
+            reload();
49
+        }
50
+    };
51
+}
52
+
27 53
 /**
28 54
  * Signals that suspend was detected.
29 55
  *

+ 4
- 2
react/features/overlay/components/AbstractPageReloadOverlay.js Просмотреть файл

@@ -4,7 +4,7 @@ import React, { Component } from 'react';
4 4
 
5 5
 import { randomInt } from '../../base/util';
6 6
 
7
-import { reconnectNow } from '../functions';
7
+import { _reloadNow } from '../actions';
8 8
 import ReloadButton from './ReloadButton';
9 9
 
10 10
 declare var AJS: Object;
@@ -22,6 +22,8 @@ export default class AbstractPageReloadOverlay extends Component {
22 22
      * @static
23 23
      */
24 24
     static propTypes = {
25
+        dispatch: React.PropTypes.func,
26
+
25 27
         /**
26 28
          * The indicator which determines whether the reload was caused by
27 29
          * network failure.
@@ -149,7 +151,7 @@ export default class AbstractPageReloadOverlay extends Component {
149 151
                                 this._interval = undefined;
150 152
                             }
151 153
 
152
-                            reconnectNow();
154
+                            this.props.dispatch(_reloadNow());
153 155
                         } else {
154 156
                             this.setState(prevState => {
155 157
                                 return {

+ 2
- 1
react/features/overlay/components/PageReloadFilmstripOnlyOverlay.js Просмотреть файл

@@ -1,4 +1,5 @@
1 1
 import React from 'react';
2
+import { connect } from 'react-redux';
2 3
 
3 4
 import { translate } from '../../base/i18n';
4 5
 
@@ -38,4 +39,4 @@ class PageReloadFilmstripOnlyOverlay extends AbstractPageReloadOverlay {
38 39
     }
39 40
 }
40 41
 
41
-export default translate(PageReloadFilmstripOnlyOverlay);
42
+export default translate(connect()(PageReloadFilmstripOnlyOverlay));

+ 2
- 1
react/features/overlay/components/PageReloadOverlay.js Просмотреть файл

@@ -1,4 +1,5 @@
1 1
 import React from 'react';
2
+import { connect } from 'react-redux';
2 3
 
3 4
 import { translate } from '../../base/i18n';
4 5
 
@@ -39,4 +40,4 @@ class PageReloadOverlay extends AbstractPageReloadOverlay {
39 40
     }
40 41
 }
41 42
 
42
-export default translate(PageReloadOverlay);
43
+export default translate(connect()(PageReloadOverlay));

+ 31
- 5
react/features/overlay/components/ReloadButton.js Просмотреть файл

@@ -1,8 +1,9 @@
1 1
 import React, { Component } from 'react';
2
+import { connect } from 'react-redux';
2 3
 
3 4
 import { translate } from '../../base/i18n';
4 5
 
5
-import { reconnectNow } from '../functions';
6
+import { _reloadNow } from '../actions';
6 7
 
7 8
 /**
8 9
  * Implements a React Component for button for the overlays that will reload
@@ -15,6 +16,13 @@ class ReloadButton extends Component {
15 16
      * @static
16 17
      */
17 18
     static propTypes = {
19
+        /**
20
+         * Reloads the page.
21
+         *
22
+         * @type {Function}
23
+         */
24
+        _reloadNow: React.PropTypes.func,
25
+
18 26
         /**
19 27
          * The function to translate human-readable text.
20 28
          *
@@ -40,15 +48,14 @@ class ReloadButton extends Component {
40 48
     render() {
41 49
         const className
42 50
             = 'button-control button-control_overlay button-control_center';
43
-        const { t } = this.props;
44 51
 
45 52
         /* eslint-disable react/jsx-handler-names */
46 53
 
47 54
         return (
48 55
             <button
49 56
                 className = { className }
50
-                onClick = { reconnectNow }>
51
-                { t(this.props.textKey) }
57
+                onClick = { this.props._reloadNow }>
58
+                { this.props.t(this.props.textKey) }
52 59
             </button>
53 60
         );
54 61
 
@@ -56,6 +63,25 @@ class ReloadButton extends Component {
56 63
     }
57 64
 }
58 65
 
66
+/**
67
+ * Maps part of redux actions to component's props.
68
+ *
69
+ * @param {Function} dispatch - Redux's {@code dispatch} function.
70
+ * @private
71
+ * @returns {Object}
72
+ */
73
+function _mapDispatchToProps(dispatch: Function): Object {
74
+    return {
75
+        /**
76
+         * Dispatches the redux action to reload the page.
77
+         *
78
+         * @protected
79
+         * @returns {Object} Dispatched action.
80
+         */
81
+        _reloadNow() {
82
+            return dispatch(_reloadNow());
83
+        }
84
+    };
59 85
 }
60 86
 
61
-export default translate(ReloadButton);
87
+export default translate(connect(undefined, _mapDispatchToProps)(ReloadButton));

+ 0
- 12
react/features/overlay/functions.js Просмотреть файл

@@ -1,12 +0,0 @@
1
-/* global APP */
2
-/**
3
- * Reloads the page.
4
- *
5
- * @returns {void}
6
- * @protected
7
- */
8
-export function reconnectNow() {
9
-    // FIXME: In future we should dispatch an action here that will result
10
-    // in reload.
11
-    APP.ConferenceUrl.reload();
12
-}

Загрузка…
Отмена
Сохранить