Przeglądaj źródła

Move ConferenceUrl.reload into React and redux

j8
Lyubo Marinov 8 lat temu
rodzic
commit
e2afb4c7e7

+ 1
- 34
modules/URL/ConferenceUrl.js Wyświetl plik

1
 const logger = require("jitsi-meet-logger").getLogger(__filename);
1
 const logger = require("jitsi-meet-logger").getLogger(__filename);
2
 
2
 
3
-import { reload, replace } from '../util/helpers';
4
-
5
 /**
3
 /**
6
  * The modules stores information about the URL used to start the conference and
4
  * The modules stores information about the URL used to start the conference and
7
  * provides utility methods for dealing with conference URL and reloads.
5
  * provides utility methods for dealing with conference URL and reloads.
18
      *
16
      *
19
      * @param location.href full URL with all parameters, would be the whole URL
17
      * @param location.href full URL with all parameters, would be the whole URL
20
      * from the example string above.
18
      * from the example string above.
21
-     *
22
      * @param location.host the host part of the URL, 'example.com' from
19
      * @param location.host the host part of the URL, 'example.com' from
23
      * the sample URL above.
20
      * the sample URL above.
24
-     *
25
      * @param location.pathname the path part of the URL, would be
21
      * @param location.pathname the path part of the URL, would be
26
      * '/SomeConference1245' from the example above.
22
      * '/SomeConference1245' from the example above.
27
-     *
28
      * @param location.protocol the protocol part of the URL, would be 'https:'
23
      * @param location.protocol the protocol part of the URL, would be 'https:'
29
      * from the sample URL.
24
      * from the sample URL.
30
      */
25
      */
31
     constructor(location) {
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
          * A simplified version of the conference URL stripped out of
28
          * A simplified version of the conference URL stripped out of
41
          * the parameters which should be used for sending invites.
29
          * the parameters which should be used for sending invites.
45
          */
33
          */
46
         this.inviteURL
34
         this.inviteURL
47
             = location.protocol + "//" + location.host + location.pathname;
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
         logger.info("Conference URL for invites: " + this.inviteURL);
37
         logger.info("Conference URL for invites: " + this.inviteURL);
50
     }
38
     }
51
     /**
39
     /**
56
     getInviteUrl() {
44
     getInviteUrl() {
57
         return this.inviteURL;
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 Wyświetl plik

1
+import { reload, replace } from '../../../modules/util/helpers';
2
+
1
 import {
3
 import {
2
     MEDIA_PERMISSION_PROMPT_VISIBILITY_CHANGED,
4
     MEDIA_PERMISSION_PROMPT_VISIBILITY_CHANGED,
3
     SUSPEND_DETECTED
5
     SUSPEND_DETECTED
4
 } from './actionTypes';
6
 } from './actionTypes';
5
 
7
 
8
+const logger = require('jitsi-meet-logger').getLogger(__filename);
9
+
6
 /**
10
 /**
7
  * Signals that the prompt for media permission is visible or not.
11
  * Signals that the prompt for media permission is visible or not.
8
  *
12
  *
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
  * Signals that suspend was detected.
54
  * Signals that suspend was detected.
29
  *
55
  *

+ 4
- 2
react/features/overlay/components/AbstractPageReloadOverlay.js Wyświetl plik

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

+ 2
- 1
react/features/overlay/components/PageReloadFilmstripOnlyOverlay.js Wyświetl plik

1
 import React from 'react';
1
 import React from 'react';
2
+import { connect } from 'react-redux';
2
 
3
 
3
 import { translate } from '../../base/i18n';
4
 import { translate } from '../../base/i18n';
4
 
5
 
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 Wyświetl plik

1
 import React from 'react';
1
 import React from 'react';
2
+import { connect } from 'react-redux';
2
 
3
 
3
 import { translate } from '../../base/i18n';
4
 import { translate } from '../../base/i18n';
4
 
5
 
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 Wyświetl plik

1
 import React, { Component } from 'react';
1
 import React, { Component } from 'react';
2
+import { connect } from 'react-redux';
2
 
3
 
3
 import { translate } from '../../base/i18n';
4
 import { translate } from '../../base/i18n';
4
 
5
 
5
-import { reconnectNow } from '../functions';
6
+import { _reloadNow } from '../actions';
6
 
7
 
7
 /**
8
 /**
8
  * Implements a React Component for button for the overlays that will reload
9
  * Implements a React Component for button for the overlays that will reload
15
      * @static
16
      * @static
16
      */
17
      */
17
     static propTypes = {
18
     static propTypes = {
19
+        /**
20
+         * Reloads the page.
21
+         *
22
+         * @type {Function}
23
+         */
24
+        _reloadNow: React.PropTypes.func,
25
+
18
         /**
26
         /**
19
          * The function to translate human-readable text.
27
          * The function to translate human-readable text.
20
          *
28
          *
40
     render() {
48
     render() {
41
         const className
49
         const className
42
             = 'button-control button-control_overlay button-control_center';
50
             = 'button-control button-control_overlay button-control_center';
43
-        const { t } = this.props;
44
 
51
 
45
         /* eslint-disable react/jsx-handler-names */
52
         /* eslint-disable react/jsx-handler-names */
46
 
53
 
47
         return (
54
         return (
48
             <button
55
             <button
49
                 className = { className }
56
                 className = { className }
50
-                onClick = { reconnectNow }>
51
-                { t(this.props.textKey) }
57
+                onClick = { this.props._reloadNow }>
58
+                { this.props.t(this.props.textKey) }
52
             </button>
59
             </button>
53
         );
60
         );
54
 
61
 
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 Wyświetl plik

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
-}

Ładowanie…
Anuluj
Zapisz