ソースを参照

LIB_DID_DISPOSE, LIB_DID_INIT, LIB_WILL_DISPOSE, LIB_WILL_INIT

j8
Lyubo Marinov 8年前
コミット
0b9160fb75

+ 27
- 6
react/features/base/lib-jitsi-meet/actionTypes.js ファイルの表示

1
 import { Symbol } from '../react';
1
 import { Symbol } from '../react';
2
 
2
 
3
 /**
3
 /**
4
- * Action to signal that lib-jitsi-meet library was disposed.
4
+ * The type of Redux action which signals that {@link JitsiMeetJS} was disposed.
5
  *
5
  *
6
  * {
6
  * {
7
- *     type: LIB_DISPOSED
7
+ *     type: LIB_DID_DISPOSE
8
  * }
8
  * }
9
  */
9
  */
10
-export const LIB_DISPOSED = Symbol('LIB_DISPOSED');
10
+export const LIB_DID_DISPOSE = Symbol('LIB_DID_DISPOSE');
11
+
12
+/**
13
+ * The type of Redux action which signals that {@link JitsiMeetJS.init()} was
14
+ * invoked and completed successfully.
15
+ *
16
+ * {
17
+ *     type: LIB_DID_INIT
18
+ * }
19
+ */
20
+export const LIB_DID_INIT = Symbol('LIB_DID_INIT');
11
 
21
 
12
 /**
22
 /**
13
  * Action to signal that lib-jitsi-meet initialized failed with error.
23
  * Action to signal that lib-jitsi-meet initialized failed with error.
20
 export const LIB_INIT_ERROR = Symbol('LIB_INIT_ERROR');
30
 export const LIB_INIT_ERROR = Symbol('LIB_INIT_ERROR');
21
 
31
 
22
 /**
32
 /**
23
- * Action to signal that lib-jitsi-meet initialization succeeded.
33
+ * The type of Redux action which signals that {@link JitsiMeetJS} will be
34
+ * disposed.
35
+ *
36
+ * {
37
+ *     type: LIB_WILL_DISPOSE
38
+ * }
39
+ */
40
+export const LIB_WILL_DISPOSE = Symbol('LIB_WILL_DISPOSE');
41
+
42
+/**
43
+ * The type of Redux action which signals that {@link JitsiMeetJS.init()} will
44
+ * be invoked.
24
  *
45
  *
25
  * {
46
  * {
26
- *     type: LIB_INITIALIZED
47
+ *     type: LIB_WILL_INIT
27
  * }
48
  * }
28
  */
49
  */
29
-export const LIB_INITIALIZED = Symbol('LIB_INITIALIZED');
50
+export const LIB_WILL_INIT = Symbol('LIB_WILL_INIT');
30
 
51
 
31
 /**
52
 /**
32
  * Action to signal that config was set.
53
  * Action to signal that config was set.

+ 28
- 20
react/features/base/lib-jitsi-meet/actions.js ファイルの表示

4
 
4
 
5
 import JitsiMeetJS from './';
5
 import JitsiMeetJS from './';
6
 import {
6
 import {
7
-    LIB_DISPOSED,
7
+    LIB_DID_DISPOSE,
8
+    LIB_DID_INIT,
8
     LIB_INIT_ERROR,
9
     LIB_INIT_ERROR,
9
-    LIB_INITIALIZED,
10
+    LIB_WILL_DISPOSE,
11
+    LIB_WILL_INIT,
10
     SET_CONFIG
12
     SET_CONFIG
11
 } from './actionTypes';
13
 } from './actionTypes';
12
 
14
 
13
 declare var APP: Object;
15
 declare var APP: Object;
14
 
16
 
15
 /**
17
 /**
16
- * Disposes lib-jitsi-meet.
18
+ * Disposes (of) lib-jitsi-meet.
17
  *
19
  *
18
  * @returns {Function}
20
  * @returns {Function}
19
  */
21
  */
20
 export function disposeLib() {
22
 export function disposeLib() {
21
-    // XXX We're wrapping it with Promise, because:
22
-    // a) to be better aligned with initLib() method, which is async.
23
-    // b) as currently there is no implementation for it in lib-jitsi-meet, and
24
-    // there is a big chance it will be async.
25
-    // TODO Currently, lib-jitsi-meet doesn't have any functionality to
26
-    // dispose itself.
27
     return (dispatch: Dispatch<*>) => {
23
     return (dispatch: Dispatch<*>) => {
28
-        dispatch({ type: LIB_DISPOSED });
24
+        dispatch({ type: LIB_WILL_DISPOSE });
29
 
25
 
30
-        return Promise.resolve();
26
+        // XXX We're wrapping it with Promise because:
27
+        // a) to be better aligned with initLib() method which is async;
28
+        // b) as currently there is no implementation for it in lib-jitsi-meet
29
+        //    and there is a big chance it will be async.
30
+        // TODO Currently, lib-jitsi-meet doesn't have the functionality to
31
+        // dispose itself.
32
+        return (
33
+            Promise.resolve()
34
+                .then(() => dispatch({ type: LIB_DID_DISPOSE })));
31
     };
35
     };
32
 }
36
 }
33
 
37
 
34
 /**
38
 /**
35
- * Initializes lib-jitsi-meet with passed configuration.
39
+ * Initializes lib-jitsi-meet (i.e. {@link invokes JitsiMeetJS.init()}) with the
40
+ * current config(uration).
36
  *
41
  *
37
  * @returns {Function}
42
  * @returns {Function}
38
  */
43
  */
50
             return Promise.resolve();
55
             return Promise.resolve();
51
         }
56
         }
52
 
57
 
53
-        return JitsiMeetJS.init(config)
54
-            .then(() => dispatch({ type: LIB_INITIALIZED }))
55
-            .catch(error => {
56
-                dispatch(libInitError(error));
58
+        dispatch({ type: LIB_WILL_INIT });
57
 
59
 
58
-                // TODO Handle LIB_INIT_ERROR error somewhere instead.
59
-                console.error('lib-jitsi-meet failed to init:', error);
60
-                throw error;
61
-            });
60
+        return (
61
+            JitsiMeetJS.init(config)
62
+                .then(() => dispatch({ type: LIB_DID_INIT }))
63
+                .catch(error => {
64
+                    dispatch(libInitError(error));
65
+
66
+                    // TODO Handle LIB_INIT_ERROR error somewhere instead.
67
+                    console.error('lib-jitsi-meet failed to init:', error);
68
+                    throw error;
69
+                }));
62
     };
70
     };
63
 }
71
 }
64
 
72
 

+ 3
- 5
react/features/base/lib-jitsi-meet/middleware.js ファイルの表示

1
 import { PARTICIPANT_LEFT } from '../participants';
1
 import { PARTICIPANT_LEFT } from '../participants';
2
 import { MiddlewareRegistry } from '../redux';
2
 import { MiddlewareRegistry } from '../redux';
3
 
3
 
4
-import {
5
-    disposeLib,
6
-    initLib
7
-} from './actions';
4
+import { disposeLib, initLib } from './actions';
8
 import { SET_CONFIG } from './actionTypes';
5
 import { SET_CONFIG } from './actionTypes';
9
 
6
 
10
 /**
7
 /**
15
  *
12
  *
16
  * @param {Store} store - Redux store.
13
  * @param {Store} store - Redux store.
17
  * @returns {Function}
14
  * @returns {Function}
15
+ * @private
18
  */
16
  */
19
 MiddlewareRegistry.register(store => next => action => {
17
 MiddlewareRegistry.register(store => next => action => {
20
     switch (action.type) {
18
     switch (action.type) {
39
  * specified action to the specified store.
37
  * specified action to the specified store.
40
  * @param {Action} action - The Redux action SET_CONFIG which is being
38
  * @param {Action} action - The Redux action SET_CONFIG which is being
41
  * dispatched in the specified store.
39
  * dispatched in the specified store.
42
- * @private
43
  * @returns {Object} The new state that is the result of the reduction of the
40
  * @returns {Object} The new state that is the result of the reduction of the
44
  * specified action.
41
  * specified action.
42
+ * @private
45
  */
43
  */
46
 function _setConfig(store, next, action) {
44
 function _setConfig(store, next, action) {
47
     const { dispatch, getState } = store;
45
     const { dispatch, getState } = store;

+ 9
- 9
react/features/base/lib-jitsi-meet/reducer.js ファイルの表示

1
 import { ReducerRegistry } from '../redux';
1
 import { ReducerRegistry } from '../redux';
2
 
2
 
3
 import {
3
 import {
4
-    LIB_DISPOSED,
4
+    LIB_DID_DISPOSE,
5
+    LIB_DID_INIT,
5
     LIB_INIT_ERROR,
6
     LIB_INIT_ERROR,
6
-    LIB_INITIALIZED,
7
     SET_CONFIG
7
     SET_CONFIG
8
 } from './actionTypes';
8
 } from './actionTypes';
9
 
9
 
46
     'features/base/lib-jitsi-meet',
46
     'features/base/lib-jitsi-meet',
47
     (state = INITIAL_STATE, action) => {
47
     (state = INITIAL_STATE, action) => {
48
         switch (action.type) {
48
         switch (action.type) {
49
-        case LIB_DISPOSED:
49
+        case LIB_DID_DISPOSE:
50
             return INITIAL_STATE;
50
             return INITIAL_STATE;
51
 
51
 
52
-        case LIB_INIT_ERROR:
52
+        case LIB_DID_INIT:
53
             return {
53
             return {
54
                 ...state,
54
                 ...state,
55
-                initError: action.error,
56
-                initialized: false
55
+                initError: undefined,
56
+                initialized: true
57
             };
57
             };
58
 
58
 
59
-        case LIB_INITIALIZED:
59
+        case LIB_INIT_ERROR:
60
             return {
60
             return {
61
                 ...state,
61
                 ...state,
62
-                initError: undefined,
63
-                initialized: true
62
+                initError: action.error,
63
+                initialized: false
64
             };
64
             };
65
 
65
 
66
         case SET_CONFIG:
66
         case SET_CONFIG:

+ 8
- 8
react/features/base/tracks/middleware.js ファイルの表示

1
 /* @flow */
1
 /* @flow */
2
 
2
 
3
-import { LIB_DISPOSED, LIB_INITIALIZED } from '../lib-jitsi-meet';
3
+import { LIB_DID_DISPOSE, LIB_DID_INIT } from '../lib-jitsi-meet';
4
 import {
4
 import {
5
     MEDIA_TYPE,
5
     MEDIA_TYPE,
6
     SET_AUDIO_MUTED,
6
     SET_AUDIO_MUTED,
16
 import { getLocalTrack, setTrackMuted } from './functions';
16
 import { getLocalTrack, setTrackMuted } from './functions';
17
 
17
 
18
 /**
18
 /**
19
- * Middleware that captures LIB_INITIALIZED and LIB_DISPOSED actions
20
- * and respectively creates/destroys local media tracks. Also listens to media-
21
- * related actions and performs corresponding operations with tracks.
19
+ * Middleware that captures LIB_DID_DISPOSE and LIB_DID_INIT actions and,
20
+ * respectively, creates/destroys local media tracks. Also listens to
21
+ * media-related actions and performs corresponding operations with tracks.
22
  *
22
  *
23
  * @param {Store} store - Redux store.
23
  * @param {Store} store - Redux store.
24
  * @returns {Function}
24
  * @returns {Function}
25
  */
25
  */
26
 MiddlewareRegistry.register(store => next => action => {
26
 MiddlewareRegistry.register(store => next => action => {
27
     switch (action.type) {
27
     switch (action.type) {
28
-    case LIB_INITIALIZED:
29
-        store.dispatch(createLocalTracks());
28
+    case LIB_DID_DISPOSE:
29
+        store.dispatch(destroyLocalTracks());
30
         break;
30
         break;
31
 
31
 
32
-    case LIB_DISPOSED:
33
-        store.dispatch(destroyLocalTracks());
32
+    case LIB_DID_INIT:
33
+        store.dispatch(createLocalTracks());
34
         break;
34
         break;
35
 
35
 
36
     case SET_AUDIO_MUTED:
36
     case SET_AUDIO_MUTED:

読み込み中…
キャンセル
保存