|
@@ -1,16 +1,24 @@
|
1
|
1
|
import { setRoom } from '../base/conference';
|
2
|
2
|
import { getDomain, setDomain } from '../base/connection';
|
3
|
3
|
import { loadConfig, setConfig } from '../base/lib-jitsi-meet';
|
4
|
|
-import { Platform } from '../base/react';
|
5
|
4
|
|
6
|
5
|
import { APP_WILL_MOUNT, APP_WILL_UNMOUNT } from './actionTypes';
|
7
|
6
|
import {
|
8
|
7
|
_getRoomAndDomainFromUrlString,
|
9
|
8
|
_getRouteToRender,
|
|
9
|
+ areRoutesEqual,
|
10
|
10
|
init
|
11
|
11
|
} from './functions';
|
12
|
12
|
import './reducer';
|
13
|
13
|
|
|
14
|
+/**
|
|
15
|
+ * Variable saving current route of the app. Later it will be extracted as
|
|
16
|
+ * a property of the class with Router specific logic.
|
|
17
|
+ *
|
|
18
|
+ * @type {Object}
|
|
19
|
+ */
|
|
20
|
+let currentRoute = {};
|
|
21
|
+
|
14
|
22
|
/**
|
15
|
23
|
* Temporary solution. Should dispatch actions related to initial settings of
|
16
|
24
|
* the app like setting log levels, reading the config parameters from query
|
|
@@ -42,9 +50,7 @@ export function appNavigate(urlOrRoom) {
|
42
|
50
|
// current conference and start a new one with the new room name or
|
43
|
51
|
// domain.
|
44
|
52
|
|
45
|
|
- if (room === 'mobile-app') {
|
46
|
|
- return;
|
47
|
|
- } else if (typeof domain === 'undefined' || oldDomain === domain) {
|
|
53
|
+ if (typeof domain === 'undefined' || oldDomain === domain) {
|
48
|
54
|
// If both domain and room vars became undefined, that means we're
|
49
|
55
|
// actually dealing with just room name and not with URL.
|
50
|
56
|
dispatch(
|
|
@@ -63,7 +69,15 @@ export function appNavigate(urlOrRoom) {
|
63
|
69
|
loadConfig(`https://${domain}`)
|
64
|
70
|
.then(
|
65
|
71
|
config => configLoaded(/* err */ undefined, config),
|
66
|
|
- err => configLoaded(err, /* config */ undefined));
|
|
72
|
+ err => configLoaded(err, /* config */ undefined))
|
|
73
|
+ .then(() => {
|
|
74
|
+ const link = typeof room === 'undefined'
|
|
75
|
+ && typeof domain === 'undefined'
|
|
76
|
+ ? urlOrRoom
|
|
77
|
+ : room;
|
|
78
|
+
|
|
79
|
+ dispatch(_setRoomAndNavigate(link));
|
|
80
|
+ });
|
67
|
81
|
}
|
68
|
82
|
|
69
|
83
|
/**
|
|
@@ -87,9 +101,6 @@ export function appNavigate(urlOrRoom) {
|
87
|
101
|
return;
|
88
|
102
|
}
|
89
|
103
|
|
90
|
|
- // We set room name only here to prevent race conditions on app
|
91
|
|
- // start to not make app re-render conference page for two times.
|
92
|
|
- dispatch(setRoom(room));
|
93
|
104
|
dispatch(setConfig(config));
|
94
|
105
|
}
|
95
|
106
|
};
|
|
@@ -127,20 +138,6 @@ export function appWillUnmount(app) {
|
127
|
138
|
};
|
128
|
139
|
}
|
129
|
140
|
|
130
|
|
-/**
|
131
|
|
- * Navigates to route corresponding to current room name.
|
132
|
|
- *
|
133
|
|
- * @param {Object} state - Redux state.
|
134
|
|
- * @private
|
135
|
|
- * @returns {void}
|
136
|
|
- */
|
137
|
|
-function _navigate(state) {
|
138
|
|
- const app = state['features/app'].app;
|
139
|
|
- const routeToRender = _getRouteToRender(state);
|
140
|
|
-
|
141
|
|
- app._navigate(routeToRender);
|
142
|
|
-}
|
143
|
|
-
|
144
|
141
|
/**
|
145
|
142
|
* Sets room and navigates to new route if needed.
|
146
|
143
|
*
|
|
@@ -150,21 +147,15 @@ function _navigate(state) {
|
150
|
147
|
*/
|
151
|
148
|
function _setRoomAndNavigate(newRoom) {
|
152
|
149
|
return (dispatch, getState) => {
|
153
|
|
- const oldRoom = getState()['features/base/conference'].room;
|
154
|
|
-
|
155
|
150
|
dispatch(setRoom(newRoom));
|
156
|
151
|
|
157
|
152
|
const state = getState();
|
158
|
|
- const { room } = state['features/base/conference'];
|
159
|
|
- const { landingIsShown } = state['features/unsupported-browser'];
|
160
|
|
-
|
161
|
|
- // If the user agent is a mobile browser and landing hasn't been shown
|
162
|
|
- // yet, we should recheck which component to render.
|
163
|
|
- const OS = Platform.OS;
|
|
153
|
+ const { app } = state['features/app'];
|
|
154
|
+ const newRoute = _getRouteToRender(state);
|
164
|
155
|
|
165
|
|
- if (((OS === 'android' || OS === 'ios') && !landingIsShown)
|
166
|
|
- || room !== oldRoom) {
|
167
|
|
- _navigate(state);
|
|
156
|
+ if (!areRoutesEqual(newRoute, currentRoute)) {
|
|
157
|
+ currentRoute = newRoute;
|
|
158
|
+ app._navigate(newRoute);
|
168
|
159
|
}
|
169
|
160
|
};
|
170
|
161
|
}
|