Pārlūkot izejas kodu

feat: introduce ConferenceUrl module

We need to make sure that on the page reload all original parameters
used to load the conference are preserved. New modules helps to manage
different types of conference URLs like the one used for invites and
the one for reloading the page.
j8
paweldomas 9 gadus atpakaļ
vecāks
revīzija
f7bfe8d8bf

+ 17
- 0
app.js Parādīt failu

19
 window.toastr = require("toastr");
19
 window.toastr = require("toastr");
20
 
20
 
21
 import URLProcessor from "./modules/config/URLProcessor";
21
 import URLProcessor from "./modules/config/URLProcessor";
22
+import ConferenceUrl from './modules/URL/ConferenceUrl';
22
 import RoomnameGenerator from './modules/util/RoomnameGenerator';
23
 import RoomnameGenerator from './modules/util/RoomnameGenerator';
23
 
24
 
24
 import UI from "./modules/UI/UI";
25
 import UI from "./modules/UI/UI";
47
     return null;
48
     return null;
48
 }
49
 }
49
 
50
 
51
+/**
52
+ * Replaces current history state(replaces the URL displayed by the browser).
53
+ * @param {string} newUrl the URL string which is to be displayed by the browser
54
+ * to the user.
55
+ */
56
+function replaceHistoryState (newUrl) {
57
+    if (window.history
58
+        && typeof window.history.replaceState === 'function') {
59
+        window.history.replaceState({}, document.title, newUrl);
60
+    }
61
+}
62
+
50
 /**
63
 /**
51
  * Builds and returns the room name.
64
  * Builds and returns the room name.
52
  */
65
  */
107
 
120
 
108
 function init() {
121
 function init() {
109
     setTokenData();
122
     setTokenData();
123
+    // Initialize the conference URL handler
124
+    ConferenceUrl.init(window.location);
125
+    // Clean up the URL displayed by the browser
126
+    replaceHistoryState(ConferenceUrl.getInviteUrl());
110
     var isUIReady = APP.UI.start();
127
     var isUIReady = APP.UI.start();
111
     if (isUIReady) {
128
     if (isUIReady) {
112
         APP.conference.init({roomName: buildRoomName()}).then(function () {
129
         APP.conference.init({roomName: buildRoomName()}).then(function () {

+ 0
- 13
modules/UI/UI.js Parādīt failu

258
  */
258
  */
259
 UI.initConference = function () {
259
 UI.initConference = function () {
260
     let id = APP.conference.getMyUserId();
260
     let id = APP.conference.getMyUserId();
261
-
262
-    // Do not include query parameters in the invite URL
263
-    // "https:" + "//" + "example.com:8888" + "/SomeConference1245"
264
-    var inviteURL = window.location.protocol + "//" +
265
-        window.location.host + window.location.pathname;
266
-
267
-    this.emitEvent(UIEvents.INVITE_URL_INITIALISED, inviteURL);
268
-
269
-    // Clean up the URL displayed by the browser
270
-    if (window.history && typeof window.history.replaceState === 'function') {
271
-        window.history.replaceState({}, document.title, inviteURL);
272
-    }
273
-
274
     // Add myself to the contact list.
261
     // Add myself to the contact list.
275
     UI.ContactList.addContact(id, true);
262
     UI.ContactList.addContact(id, true);
276
 
263
 

+ 2
- 5
modules/UI/invite/Invite.js Parādīt failu

3
 import InviteDialogView from './InviteDialogView';
3
 import InviteDialogView from './InviteDialogView';
4
 import createRoomLocker from './RoomLocker';
4
 import createRoomLocker from './RoomLocker';
5
 import UIEvents from  '../../../service/UI/UIEvents';
5
 import UIEvents from  '../../../service/UI/UIEvents';
6
+import ConferenceUrl from '../../URL/ConferenceUrl';
6
 
7
 
7
 const ConferenceEvents = JitsiMeetJS.events.conference;
8
 const ConferenceEvents = JitsiMeetJS.events.conference;
8
 
9
 
14
 class Invite {
15
 class Invite {
15
     constructor(conference) {
16
     constructor(conference) {
16
         this.conference = conference;
17
         this.conference = conference;
18
+        this.inviteUrl = ConferenceUrl.getInviteUrl();
17
         this.createRoomLocker(conference);
19
         this.createRoomLocker(conference);
18
         this.registerListeners();
20
         this.registerListeners();
19
     }
21
     }
48
         APP.UI.addListener( UIEvents.INVITE_CLICKED,
50
         APP.UI.addListener( UIEvents.INVITE_CLICKED,
49
                             () => { this.openLinkDialog(); });
51
                             () => { this.openLinkDialog(); });
50
 
52
 
51
-        APP.UI.addListener( UIEvents.INVITE_URL_INITIALISED,
52
-                            (inviteUrl) => {
53
-                                this.updateInviteUrl(inviteUrl);
54
-                            });
55
-
56
         APP.UI.addListener( UIEvents.PASSWORD_REQUIRED,
53
         APP.UI.addListener( UIEvents.PASSWORD_REQUIRED,
57
             () => {
54
             () => {
58
                 this.setLockedFromElsewhere(true);
55
                 this.setLockedFromElsewhere(true);

+ 2
- 3
modules/UI/reload_overlay/PageReloadOverlay.js Parādīt failu

1
 /* global $, APP, AJS */
1
 /* global $, APP, AJS */
2
 
2
 
3
-import { reload } from '../../util/helpers';
3
+import ConferenceUrl from '../../URL/ConferenceUrl';
4
 
4
 
5
 let $overlay;
5
 let $overlay;
6
 
6
 
78
         updateDisplay();
78
         updateDisplay();
79
 
79
 
80
         if (timeLeft === 0) {
80
         if (timeLeft === 0) {
81
-            console.info("Reloading!");
82
             window.clearInterval(intervalId);
81
             window.clearInterval(intervalId);
83
-            reload();
82
+            ConferenceUrl.reload();
84
         }
83
         }
85
     }, 1000);
84
     }, 1000);
86
 }
85
 }

+ 73
- 0
modules/URL/ConferenceUrl.js Parādīt failu

1
+
2
+import { redirect } from '../util/helpers';
3
+
4
+/**
5
+ * Stores the original conference room URL with all parameters.
6
+ * @type {string}
7
+ */
8
+let originalURL;
9
+
10
+/**
11
+ * A simplified version of the conference URL stripped out of the parameters
12
+ * which should be used for sending invites.
13
+ * @type {string}
14
+ */
15
+let inviteURL;
16
+
17
+/**
18
+ * The modules stores information about the URL used to start the conference and
19
+ * provides utility methods for dealing with conference URL and reloads.
20
+ */
21
+export default {
22
+    /**
23
+     * Initializes the module.
24
+     *
25
+     * @param location an object which stores provides the info about conference
26
+     * URL(would be 'window.location' for the Web app). The params below are
27
+     * described based on the following example URL:
28
+     *
29
+     * https://example.com:8888/SomeConference1245?opt=1#somehash
30
+     *
31
+     * @param location.href full URL with all parameters, would be the whole URL
32
+     * from the example string above.
33
+     *
34
+     * @param location.host the host part of the URL, 'example.com' from
35
+     * the sample URL above.
36
+     *
37
+     * @param location.pathname the path part of the URL, would be
38
+     * '/SomeConference1245' from the example above.
39
+     *
40
+     * @param location.protocol the protocol part of the URL, would be 'https:'
41
+     * from the sample URL.
42
+     */
43
+    init(location) {
44
+        originalURL = location.href;
45
+        // "https:" + "//" + "example.com:8888" + "/SomeConference1245"
46
+        inviteURL
47
+            = location.protocol + "//" + location.host + location.pathname;
48
+        console.info("Stored original conference URL: " + originalURL);
49
+        console.info("Conference URL for invites: " + inviteURL);
50
+    },
51
+    /**
52
+     * Obtains the conference invite URL.
53
+     * @return {string} the URL pointing o the conference which is mean to be
54
+     * used to invite new participants.
55
+     */
56
+    getInviteUrl() {
57
+        return inviteURL;
58
+    },
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 originalURL;
65
+    },
66
+    /**
67
+     * Reloads the conference using original URL with all of the parameters.
68
+     */
69
+    reload() {
70
+        console.info("Reloading the conference using URL: " + originalURL);
71
+        redirect(originalURL);
72
+    }
73
+};

+ 9
- 0
modules/util/helpers.js Parādīt failu

20
     window.location.reload();
20
     window.location.reload();
21
 }
21
 }
22
 
22
 
23
+/**
24
+ * Redirects to new URL.
25
+ * @param {string} url the URL pointing to the location where the user should
26
+ * be redirected to.
27
+ */
28
+export function redirect (url) {
29
+    window.location.replace(url);
30
+}
31
+
23
 /**
32
 /**
24
  * Prints the error and reports it to the global error handler.
33
  * Prints the error and reports it to the global error handler.
25
  * @param e {Error} the error
34
  * @param e {Error} the error

+ 0
- 5
service/UI/UIEvents.js Parādīt failu

145
      */
145
      */
146
     DISPLAY_NAME_CHANGED: "UI.display_name_changed",
146
     DISPLAY_NAME_CHANGED: "UI.display_name_changed",
147
 
147
 
148
-    /**
149
-     * Indicates that the invite url has been initialised.
150
-     */
151
-    INVITE_URL_INITIALISED: "UI.invite_url_initialised",
152
-
153
     /**
148
     /**
154
      * Indicates that a password is required for the call.
149
      * Indicates that a password is required for the call.
155
      */
150
      */

Notiek ielāde…
Atcelt
Saglabāt