Explorar el Código

[RN] Use a more resilient way for testing if we are on React Native

navigator.product is read-only, so we don't run into the risk of it being
changed.
master
Saúl Ibarra Corretgé hace 8 años
padre
commit
1d90826098
Se han modificado 2 ficheros con 2 adiciones y 2 borrados
  1. 1
    1
      react/features/app/middleware.js
  2. 1
    1
      react/features/base/config/reducer.js

+ 1
- 1
react/features/app/middleware.js Ver fichero

83
     // abstraction. Because of the first point, I'm leaving the second point
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
84
     // unresolved to attract attention to the fact that the following needs more
85
     // thinking.
85
     // thinking.
86
-    if (navigator.userAgent.match(/react[ \s-]*native/i)) {
86
+    if (navigator.product === 'ReactNative') {
87
         // Create/destroy the local tracks as needed: create them the first time
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
88
         // we are going to render an actual route (be that the WelcomePage or
89
         // the Conference).
89
         // the Conference).

+ 1
- 1
react/features/base/config/reducer.js Ver fichero

73
  */
73
  */
74
 function _getInitialState() {
74
 function _getInitialState() {
75
     return (
75
     return (
76
-        navigator.userAgent.match(/react[ \s-]*native/i)
76
+        navigator.product === 'ReactNative'
77
             ? INITIAL_RN_STATE
77
             ? INITIAL_RN_STATE
78
             : INITIAL_NON_RN_STATE);
78
             : INITIAL_NON_RN_STATE);
79
 }
79
 }

Loading…
Cancelar
Guardar