Ver código fonte

feat: pass network info to LJM

master
paweldomas 5 anos atrás
pai
commit
bc43f00d28

+ 7
- 1
react/features/base/lib-jitsi-meet/actions.js Ver arquivo

@@ -2,6 +2,8 @@
2 2
 
3 3
 import type { Dispatch } from 'redux';
4 4
 
5
+import { isOnline } from '../net-info/selectors';
6
+
5 7
 import JitsiMeetJS from './_';
6 8
 import {
7 9
     LIB_DID_DISPOSE,
@@ -37,7 +39,8 @@ export function disposeLib() {
37 39
  */
38 40
 export function initLib() {
39 41
     return (dispatch: Dispatch<any>, getState: Function): void => {
40
-        const config = getState()['features/base/config'];
42
+        const state = getState();
43
+        const config = state['features/base/config'];
41 44
 
42 45
         if (!config) {
43 46
             throw new Error('Cannot init lib-jitsi-meet without config');
@@ -50,6 +53,9 @@ export function initLib() {
50 53
                 enableAnalyticsLogging: isAnalyticsEnabled(getState),
51 54
                 ...config
52 55
             });
56
+            JitsiMeetJS.setNetworkInfo({
57
+                isOnline: isOnline(state)
58
+            });
53 59
             dispatch({ type: LIB_DID_INIT });
54 60
         } catch (error) {
55 61
             dispatch(libInitError(error));

+ 7
- 0
react/features/base/lib-jitsi-meet/middleware.js Ver arquivo

@@ -2,6 +2,7 @@
2 2
 
3 3
 import { SET_CONFIG } from '../config';
4 4
 import { setLoggingConfig } from '../logging';
5
+import { SET_NETWORK_INFO } from '../net-info';
5 6
 import { PARTICIPANT_LEFT } from '../participants';
6 7
 import { MiddlewareRegistry } from '../redux';
7 8
 
@@ -31,6 +32,12 @@ MiddlewareRegistry.register(store => next => action => {
31 32
         }
32 33
         break;
33 34
 
35
+    case SET_NETWORK_INFO:
36
+        JitsiMeetJS.setNetworkInfo({
37
+            isOnline: action.isOnline
38
+        });
39
+        break;
40
+
34 41
     case PARTICIPANT_LEFT:
35 42
         action.participant.local && store.dispatch(disposeLib());
36 43
         break;

+ 11
- 0
react/features/base/net-info/selectors.js Ver arquivo

@@ -0,0 +1,11 @@
1
+import { STORE_NAME } from './constants';
2
+
3
+/**
4
+ * A selector for the internet online status.
5
+ *
6
+ * @param {Object} state - The redux state.
7
+ * @returns {boolean}
8
+ */
9
+export function isOnline(state) {
10
+    return state[STORE_NAME].isOnline;
11
+}

Carregando…
Cancelar
Salvar