Преглед на файлове

Adds option to be able to cancel locked rooms and leave. (#4391)

* Adds option to be able to cancel locked rooms and leave.

* Removes not needed operations when canceling password prompt.
master
Дамян Минков преди 6 години
родител
ревизия
2dc06c28e3
No account linked to committer's email address
променени са 4 файла, в които са добавени 136 реда и са изтрити 82 реда
  1. 5
    78
      conference.js
  2. 93
    2
      react/features/app/actions.js
  3. 16
    1
      react/features/room-lock/actions.js
  4. 22
    1
      react/features/room-lock/components/PasswordRequiredPrompt.web.js

+ 5
- 78
conference.js Целия файл

@@ -23,7 +23,8 @@ import {
23 23
     sendAnalytics
24 24
 } from './react/features/analytics';
25 25
 import {
26
-    redirectWithStoredParams,
26
+    maybeRedirectToWelcomePage,
27
+    redirectToStaticPage,
27 28
     reloadWithStoredParams
28 29
 } from './react/features/app';
29 30
 
@@ -101,10 +102,7 @@ import {
101 102
     trackAdded,
102 103
     trackRemoved
103 104
 } from './react/features/base/tracks';
104
-import {
105
-    getLocationContextRoot,
106
-    getJitsiMeetGlobalNS
107
-} from './react/features/base/util';
105
+import { getJitsiMeetGlobalNS } from './react/features/base/util';
108 106
 import { addMessage } from './react/features/chat';
109 107
 import { showDesktopPicker } from './react/features/desktop-picker';
110 108
 import { appendSuffix } from './react/features/display-name';
@@ -211,77 +209,6 @@ function muteLocalVideo(muted) {
211 209
     APP.store.dispatch(setVideoMuted(muted));
212 210
 }
213 211
 
214
-/**
215
- * Check if the welcome page is enabled and redirects to it.
216
- * If requested show a thank you dialog before that.
217
- * If we have a close page enabled, redirect to it without
218
- * showing any other dialog.
219
- *
220
- * @param {object} options used to decide which particular close page to show
221
- * or if close page is disabled, whether we should show the thankyou dialog
222
- * @param {boolean} options.showThankYou - whether we should
223
- * show thank you dialog
224
- * @param {boolean} options.feedbackSubmitted - whether feedback was submitted
225
- */
226
-function maybeRedirectToWelcomePage(options) {
227
-    // if close page is enabled redirect to it, without further action
228
-    if (config.enableClosePage) {
229
-        const { isGuest } = APP.store.getState()['features/base/jwt'];
230
-
231
-        // save whether current user is guest or not, before navigating
232
-        // to close page
233
-        window.sessionStorage.setItem('guest', isGuest);
234
-        redirectToStaticPage(`static/${
235
-            options.feedbackSubmitted ? 'close.html' : 'close2.html'}`);
236
-
237
-        return;
238
-    }
239
-
240
-    // else: show thankYou dialog only if there is no feedback
241
-    if (options.showThankYou) {
242
-        APP.store.dispatch(showNotification({
243
-            titleArguments: { appName: interfaceConfig.APP_NAME },
244
-            titleKey: 'dialog.thankYou'
245
-        }));
246
-    }
247
-
248
-    // if Welcome page is enabled redirect to welcome page after 3 sec, if
249
-    // there is a thank you message to be shown, 0.5s otherwise.
250
-    if (config.enableWelcomePage) {
251
-        setTimeout(
252
-            () => {
253
-                APP.store.dispatch(redirectWithStoredParams('/'));
254
-            },
255
-            options.showThankYou ? 3000 : 500);
256
-    }
257
-}
258
-
259
-/**
260
- * Assigns a specific pathname to window.location.pathname taking into account
261
- * the context root of the Web app.
262
- *
263
- * @param {string} pathname - The pathname to assign to
264
- * window.location.pathname. If the specified pathname is relative, the context
265
- * root of the Web app will be prepended to the specified pathname before
266
- * assigning it to window.location.pathname.
267
- * @return {void}
268
- */
269
-function redirectToStaticPage(pathname) {
270
-    const windowLocation = window.location;
271
-    let newPathname = pathname;
272
-
273
-    if (!newPathname.startsWith('/')) {
274
-        // A pathname equal to ./ specifies the current directory. It will be
275
-        // fine but pointless to include it because contextRoot is the current
276
-        // directory.
277
-        newPathname.startsWith('./')
278
-            && (newPathname = newPathname.substring(2));
279
-        newPathname = getLocationContextRoot(windowLocation) + newPathname;
280
-    }
281
-
282
-    windowLocation.pathname = newPathname;
283
-}
284
-
285 212
 /**
286 213
  * A queue for the async replaceLocalTrack action so that multiple audio
287 214
  * replacements cannot happen simultaneously. This solves the issue where
@@ -347,7 +274,7 @@ class ConferenceConnector {
347 274
 
348 275
         case JitsiConferenceErrors.NOT_ALLOWED_ERROR: {
349 276
             // let's show some auth not allowed page
350
-            redirectToStaticPage('static/authError.html');
277
+            APP.store.dispatch(redirectToStaticPage('static/authError.html'));
351 278
             break;
352 279
         }
353 280
 
@@ -2596,7 +2523,7 @@ export default {
2596 2523
             room = undefined;
2597 2524
 
2598 2525
             APP.API.notifyReadyToClose();
2599
-            maybeRedirectToWelcomePage(values[0]);
2526
+            APP.store.dispatch(maybeRedirectToWelcomePage(values[0]));
2600 2527
         });
2601 2528
     },
2602 2529
 

+ 93
- 2
react/features/app/actions.js Целия файл

@@ -13,10 +13,18 @@ import {
13 13
 import { connect, disconnect, setLocationURL } from '../base/connection';
14 14
 import { loadConfig } from '../base/lib-jitsi-meet';
15 15
 import { createDesiredLocalTracks } from '../base/tracks';
16
-import { parseURIString, toURLString } from '../base/util';
16
+import {
17
+    getLocationContextRoot,
18
+    parseURIString,
19
+    toURLString
20
+} from '../base/util';
21
+import { showNotification } from '../notifications';
17 22
 import { setFatalError } from '../overlay';
18 23
 
19
-import { getDefaultURL } from './functions';
24
+import {
25
+    getDefaultURL,
26
+    getName
27
+} from './functions';
20 28
 
21 29
 const logger = require('jitsi-meet-logger').getLogger(__filename);
22 30
 
@@ -136,6 +144,34 @@ export function redirectWithStoredParams(pathname: string) {
136 144
     };
137 145
 }
138 146
 
147
+/**
148
+ * Assigns a specific pathname to window.location.pathname taking into account
149
+ * the context root of the Web app.
150
+ *
151
+ * @param {string} pathname - The pathname to assign to
152
+ * window.location.pathname. If the specified pathname is relative, the context
153
+ * root of the Web app will be prepended to the specified pathname before
154
+ * assigning it to window.location.pathname.
155
+ * @returns {Function}
156
+ */
157
+export function redirectToStaticPage(pathname: string) {
158
+    return () => {
159
+        const windowLocation = window.location;
160
+        let newPathname = pathname;
161
+
162
+        if (!newPathname.startsWith('/')) {
163
+            // A pathname equal to ./ specifies the current directory. It will be
164
+            // fine but pointless to include it because contextRoot is the current
165
+            // directory.
166
+            newPathname.startsWith('./')
167
+            && (newPathname = newPathname.substring(2));
168
+            newPathname = getLocationContextRoot(windowLocation) + newPathname;
169
+        }
170
+
171
+        windowLocation.pathname = newPathname;
172
+    };
173
+}
174
+
139 175
 /**
140 176
  * Reloads the page.
141 177
  *
@@ -182,3 +218,58 @@ export function reloadWithStoredParams() {
182 218
         }
183 219
     };
184 220
 }
221
+
222
+/**
223
+ * Check if the welcome page is enabled and redirects to it.
224
+ * If requested show a thank you dialog before that.
225
+ * If we have a close page enabled, redirect to it without
226
+ * showing any other dialog.
227
+ *
228
+ * @param {Object} options - Used to decide which particular close page to show
229
+ * or if close page is disabled, whether we should show the thankyou dialog.
230
+ * @param {boolean} options.showThankYou - Whether we should
231
+ * show thank you dialog.
232
+ * @param {boolean} options.feedbackSubmitted - Whether feedback was submitted.
233
+ * @returns {Function}
234
+ */
235
+export function maybeRedirectToWelcomePage(options: Object = {}) {
236
+    return (dispatch: Dispatch<any>, getState: Function) => {
237
+
238
+        const {
239
+            enableClosePage
240
+        } = getState()['features/base/config'];
241
+
242
+        // if close page is enabled redirect to it, without further action
243
+        if (enableClosePage) {
244
+            const { isGuest } = getState()['features/base/jwt'];
245
+
246
+            // save whether current user is guest or not, before navigating
247
+            // to close page
248
+            window.sessionStorage.setItem('guest', isGuest);
249
+
250
+            dispatch(redirectToStaticPage(`static/${
251
+                options.feedbackSubmitted ? 'close.html' : 'close2.html'}`));
252
+
253
+            return;
254
+        }
255
+
256
+        // else: show thankYou dialog only if there is no feedback
257
+        if (options.showThankYou) {
258
+            dispatch(showNotification({
259
+                titleArguments: { appName: getName() },
260
+                titleKey: 'dialog.thankYou'
261
+            }));
262
+        }
263
+
264
+        // if Welcome page is enabled redirect to welcome page after 3 sec, if
265
+        // there is a thank you message to be shown, 0.5s otherwise.
266
+        if (getState()['features/base/config'].enableWelcomePage) {
267
+            setTimeout(
268
+                () => {
269
+                    dispatch(redirectWithStoredParams('/'));
270
+                },
271
+                options.showThankYou ? 3000 : 500);
272
+        }
273
+    };
274
+}
275
+

+ 16
- 1
react/features/room-lock/actions.js Целия файл

@@ -2,7 +2,10 @@
2 2
 
3 3
 import type { Dispatch } from 'redux';
4 4
 
5
-import { appNavigate } from '../app';
5
+import {
6
+    appNavigate,
7
+    maybeRedirectToWelcomePage
8
+} from '../app';
6 9
 import {
7 10
     conferenceLeft,
8 11
     JITSI_CONFERENCE_URL_KEY,
@@ -11,6 +14,8 @@ import {
11 14
 import { hideDialog, openDialog } from '../base/dialog';
12 15
 import { PasswordRequiredPrompt, RoomLockPrompt } from './components';
13 16
 
17
+declare var APP: Object;
18
+
14 19
 /**
15 20
  * Begins a (user) request to lock a specific conference/room.
16 21
  *
@@ -44,6 +49,16 @@ export function beginRoomLockRequest(conference: ?Object) {
44 49
  */
45 50
 export function _cancelPasswordRequiredPrompt(conference: Object) {
46 51
     return (dispatch: Dispatch<any>, getState: Function) => {
52
+
53
+        if (typeof APP !== 'undefined') {
54
+            // when we are redirecting the library should handle any
55
+            // unload and clean of the connection.
56
+            APP.API.notifyReadyToClose();
57
+            dispatch(maybeRedirectToWelcomePage());
58
+
59
+            return;
60
+        }
61
+
47 62
         // Canceling PasswordRequiredPrompt is to navigate the app/user to
48 63
         // WelcomePage. In other words, the canceling invalidates the
49 64
         // locationURL. Make sure that the canceling indeed has the intent to

+ 22
- 1
react/features/room-lock/components/PasswordRequiredPrompt.web.js Целия файл

@@ -9,6 +9,8 @@ import { Dialog } from '../../base/dialog';
9 9
 import { translate } from '../../base/i18n';
10 10
 import { connect } from '../../base/redux';
11 11
 
12
+import { _cancelPasswordRequiredPrompt } from '../actions';
13
+
12 14
 /**
13 15
  * The type of the React {@code Component} props of
14 16
  * {@link PasswordRequiredPrompt}.
@@ -63,6 +65,7 @@ class PasswordRequiredPrompt extends Component<Props, State> {
63 65
 
64 66
         // Bind event handlers so they are only bound once per instance.
65 67
         this._onPasswordChanged = this._onPasswordChanged.bind(this);
68
+        this._onCancel = this._onCancel.bind(this);
66 69
         this._onSubmit = this._onSubmit.bind(this);
67 70
     }
68 71
 
@@ -75,7 +78,9 @@ class PasswordRequiredPrompt extends Component<Props, State> {
75 78
     render() {
76 79
         return (
77 80
             <Dialog
78
-                isModal = { true }
81
+                disableBlanketClickDismiss = { true }
82
+                isModal = { false }
83
+                onCancel = { this._onCancel }
79 84
                 onSubmit = { this._onSubmit }
80 85
                 titleKey = 'dialog.passwordRequired'
81 86
                 width = 'small'>
@@ -121,6 +126,22 @@ class PasswordRequiredPrompt extends Component<Props, State> {
121 126
         });
122 127
     }
123 128
 
129
+    _onCancel: () => boolean;
130
+
131
+    /**
132
+     * Dispatches action to cancel and dismiss this dialog.
133
+     *
134
+     * @private
135
+     * @returns {boolean}
136
+     */
137
+    _onCancel() {
138
+
139
+        this.props.dispatch(
140
+            _cancelPasswordRequiredPrompt(this.props.conference));
141
+
142
+        return true;
143
+    }
144
+
124 145
     _onSubmit: () => boolean;
125 146
 
126 147
     /**

Loading…
Отказ
Запис