Ver código fonte

[RN] Don't open the camera on startup when there is no welcome page

master
Lyubo Marinov 7 anos atrás
pai
commit
d87b8823e9
1 arquivos alterados com 25 adições e 16 exclusões
  1. 25
    16
      react/features/app/middleware.js

+ 25
- 16
react/features/app/middleware.js Ver arquivo

@@ -76,22 +76,31 @@ function _navigate({ dispatch, getState }) {
76 76
     const { app, getRouteToRender } = state['features/app'];
77 77
     const routeToRender = getRouteToRender && getRouteToRender(state);
78 78
 
79
-    // Create/destroy the local tracks as needed: create them the first time we
80
-    // are going to render an actual route (be that the WelcomePage or the
81
-    // Conference).
82
-    //
83
-    // When the WelcomePage is disabled, the app will transition to the
84
-    // null/undefined route. Detect these transitions and create/destroy the
85
-    // local tracks so the camera doesn't stay open if the app is not rendering
86
-    // any component.
87
-    if (typeof routeToRender === 'undefined' || routeToRender === null) {
88
-        // Destroy the local tracks if there is no route to render and there is
89
-        // no welcome page.
90
-        app.props.welcomePageEnabled || dispatch(destroyLocalTracks());
91
-    } else {
92
-        // Create the local tracks if they haven't been created yet.
93
-        state['features/base/tracks'].some(t => t.local)
94
-            || dispatch(createInitialLocalTracks());
79
+    // FIXME The following is logic specific to the user experience of the
80
+    // mobile/React Native app. Firstly, I don't like that it's here at all.
81
+    // Secondly, I copied the mobile/React Native detection from
82
+    // react/features/base/config/reducer.js because I couldn't iron out an
83
+    // abstraction. Because of the first point, I'm leaving the second point
84
+    // unresolved to attract attention to the fact that the following needs more
85
+    // thinking.
86
+    if (navigator.userAgent.match(/react[ \s-]*native/i)) {
87
+        // Create/destroy the local tracks as needed: create them the first time
88
+        // we are going to render an actual route (be that the WelcomePage or
89
+        // the Conference).
90
+        //
91
+        // When the WelcomePage is disabled, the app will transition to the
92
+        // null/undefined route. Detect these transitions and create/destroy the
93
+        // local tracks so the camera doesn't stay open if the app is not
94
+        // rendering any component.
95
+        if (typeof routeToRender === 'undefined' || routeToRender === null) {
96
+            // Destroy the local tracks if there is no route to render and there
97
+            // is no WelcomePage.
98
+            app.props.welcomePageEnabled || dispatch(destroyLocalTracks());
99
+        } else {
100
+            // Create the local tracks if they haven't been created yet.
101
+            state['features/base/tracks'].some(t => t.local)
102
+                || dispatch(createInitialLocalTracks());
103
+        }
95 104
     }
96 105
 
97 106
     app._navigate(routeToRender);

Carregando…
Cancelar
Salvar