|
@@ -22,24 +22,44 @@ MiddlewareRegistry.register(store => next => action => {
|
22
|
22
|
action.participant.local && store.dispatch(disposeLib());
|
23
|
23
|
break;
|
24
|
24
|
|
25
|
|
- case SET_CONFIG: {
|
26
|
|
- const { dispatch, getState } = store;
|
27
|
|
- const initialized
|
28
|
|
- = getState()['features/base/lib-jitsi-meet'].initialized;
|
29
|
|
-
|
30
|
|
- // XXX If we already have config, that means new config is coming, which
|
31
|
|
- // means that we should dispose instance of lib initialized with
|
32
|
|
- // previous config first.
|
33
|
|
- // TODO Currently 'disposeLib' actually does not dispose lib-jitsi-meet.
|
34
|
|
- // This functionality should be implemented.
|
35
|
|
- const promise
|
36
|
|
- = initialized ? dispatch(disposeLib()) : Promise.resolve();
|
37
|
|
-
|
38
|
|
- promise.then(dispatch(initLib()));
|
39
|
|
-
|
40
|
|
- break;
|
41
|
|
- }
|
|
25
|
+ case SET_CONFIG:
|
|
26
|
+ return _setConfig(store, next, action);
|
42
|
27
|
}
|
43
|
28
|
|
44
|
29
|
return next(action);
|
45
|
30
|
});
|
|
31
|
+
|
|
32
|
+/**
|
|
33
|
+ * Notifies the feature base/lib-jitsi-meet that the action SET_CONFIG is being
|
|
34
|
+ * dispatched within a specific Redux store.
|
|
35
|
+ *
|
|
36
|
+ * @param {Store} store - The Redux store in which the specified action is being
|
|
37
|
+ * dispatched.
|
|
38
|
+ * @param {Dispatch} next - The Redux dispatch function to dispatch the
|
|
39
|
+ * specified action to the specified store.
|
|
40
|
+ * @param {Action} action - The Redux action SET_CONFIG which is being
|
|
41
|
+ * dispatched in the specified store.
|
|
42
|
+ * @private
|
|
43
|
+ * @returns {Object} The new state that is the result of the reduction of the
|
|
44
|
+ * specified action.
|
|
45
|
+ */
|
|
46
|
+function _setConfig(store, next, action) {
|
|
47
|
+ const { dispatch, getState } = store;
|
|
48
|
+ const { initialized } = getState()['features/base/lib-jitsi-meet'];
|
|
49
|
+
|
|
50
|
+ // XXX Since the config is changing, the library lib-jitsi-meet must be
|
|
51
|
+ // initialized again with the new config. Consequntly, it may need to be
|
|
52
|
+ // disposed of first.
|
|
53
|
+ // TODO Currently, disposeLib actually does not dispose of lib-jitsi-meet
|
|
54
|
+ // because lib-jitsi-meet does not implement such functionality.
|
|
55
|
+ const disposeLIbPromise
|
|
56
|
+ = initialized ? dispatch(disposeLib()) : Promise.resolve();
|
|
57
|
+
|
|
58
|
+ // Let the new config into the Redux store (because initLib will read it
|
|
59
|
+ // from there).
|
|
60
|
+ const nextState = next(action);
|
|
61
|
+
|
|
62
|
+ disposeLIbPromise.then(dispatch(initLib()));
|
|
63
|
+
|
|
64
|
+ return nextState;
|
|
65
|
+}
|