|
@@ -13,8 +13,11 @@ import {
|
13
|
13
|
} from '../base/config';
|
14
|
14
|
import { connect, disconnect, setLocationURL } from '../base/connection';
|
15
|
15
|
import { loadConfig } from '../base/lib-jitsi-meet';
|
16
|
|
-import { createDesiredLocalTracks } from '../base/tracks';
|
|
16
|
+import { MEDIA_TYPE } from '../base/media';
|
|
17
|
+import { toState } from '../base/redux';
|
|
18
|
+import { createDesiredLocalTracks, isLocalVideoTrackMuted, isLocalTrackMuted } from '../base/tracks';
|
17
|
19
|
import {
|
|
20
|
+ addHashParamsToURL,
|
18
|
21
|
getBackendSafeRoomName,
|
19
|
22
|
getLocationContextRoot,
|
20
|
23
|
parseURIString,
|
|
@@ -191,18 +194,42 @@ export function reloadNow() {
|
191
|
194
|
return (dispatch: Dispatch<Function>, getState: Function) => {
|
192
|
195
|
dispatch(setFatalError(undefined));
|
193
|
196
|
|
194
|
|
- const { locationURL } = getState()['features/base/connection'];
|
|
197
|
+ const state = getState();
|
|
198
|
+ const { locationURL } = state['features/base/connection'];
|
|
199
|
+
|
|
200
|
+ // Preserve the local tracks muted state after the reload.
|
|
201
|
+ const newURL = addTrackStateToURL(locationURL, state);
|
195
|
202
|
|
196
|
203
|
logger.info(`Reloading the conference using URL: ${locationURL}`);
|
197
|
204
|
|
198
|
205
|
if (navigator.product === 'ReactNative') {
|
199
|
|
- dispatch(appNavigate(toURLString(locationURL)));
|
|
206
|
+ dispatch(appNavigate(toURLString(newURL)));
|
200
|
207
|
} else {
|
201
|
208
|
dispatch(reloadWithStoredParams());
|
202
|
209
|
}
|
203
|
210
|
};
|
204
|
211
|
}
|
205
|
212
|
|
|
213
|
+/**
|
|
214
|
+ * Adds the current track state to the passed URL.
|
|
215
|
+ *
|
|
216
|
+ * @param {URL} url - The URL that will be modified.
|
|
217
|
+ * @param {Function|Object} stateful - The redux store or {@code getState} function.
|
|
218
|
+ * @returns {URL} - Returns the modified URL.
|
|
219
|
+ */
|
|
220
|
+function addTrackStateToURL(url, stateful) {
|
|
221
|
+ const state = toState(stateful);
|
|
222
|
+ const tracks = state['features/base/tracks'];
|
|
223
|
+ const isVideoMuted = isLocalVideoTrackMuted(tracks);
|
|
224
|
+ const isAudioMuted = isLocalTrackMuted(tracks, MEDIA_TYPE.AUDIO);
|
|
225
|
+
|
|
226
|
+ return addHashParamsToURL(new URL(url), { // use new URL object in order to not pollute the passed parameter.
|
|
227
|
+ 'config.startWithAudioMuted': isAudioMuted,
|
|
228
|
+ 'config.startWithVideoMuted': isVideoMuted
|
|
229
|
+ });
|
|
230
|
+
|
|
231
|
+}
|
|
232
|
+
|
206
|
233
|
/**
|
207
|
234
|
* Reloads the page by restoring the original URL.
|
208
|
235
|
*
|
|
@@ -210,17 +237,20 @@ export function reloadNow() {
|
210
|
237
|
*/
|
211
|
238
|
export function reloadWithStoredParams() {
|
212
|
239
|
return (dispatch: Dispatch<any>, getState: Function) => {
|
213
|
|
- const { locationURL } = getState()['features/base/connection'];
|
|
240
|
+ const state = getState();
|
|
241
|
+ const { locationURL } = state['features/base/connection'];
|
|
242
|
+
|
|
243
|
+ // Preserve the local tracks muted states.
|
|
244
|
+ const newURL = addTrackStateToURL(locationURL, state);
|
214
|
245
|
const windowLocation = window.location;
|
215
|
246
|
const oldSearchString = windowLocation.search;
|
216
|
247
|
|
217
|
|
- windowLocation.replace(locationURL.toString());
|
|
248
|
+ windowLocation.replace(newURL.toString());
|
218
|
249
|
|
219
|
|
- if (window.self !== window.top
|
220
|
|
- && locationURL.search === oldSearchString) {
|
|
250
|
+ if (newURL.search === oldSearchString) {
|
221
|
251
|
// NOTE: Assuming that only the hash or search part of the URL will
|
222
|
252
|
// be changed!
|
223
|
|
- // location.reload will not trigger redirect/reload for iframe when
|
|
253
|
+ // location.replace will not trigger redirect/reload when
|
224
|
254
|
// only the hash params are changed. That's why we need to call
|
225
|
255
|
// reload in addition to replace.
|
226
|
256
|
windowLocation.reload();
|