浏览代码

ref(base/util): move getSymbolDescription to util

j8
paweldomas 6 年前
父节点
当前提交
01c2786c95
共有 2 个文件被更改,包括 29 次插入29 次删除
  1. 23
    0
      react/features/base/util/helpers.js
  2. 6
    29
      react/features/mobile/external-api/middleware.js

+ 23
- 0
react/features/base/util/helpers.js 查看文件

@@ -19,6 +19,29 @@ export function getJitsiMeetGlobalNS() {
19 19
     return window.JitsiMeetJS.app;
20 20
 }
21 21
 
22
+/**
23
+ * Gets the description of a specific {@code Symbol}.
24
+ *
25
+ * @param {Symbol} symbol - The {@code Symbol} to retrieve the description of.
26
+ * @private
27
+ * @returns {string} The description of {@code symbol}.
28
+ */
29
+export function getSymbolDescription(symbol: ?Symbol) {
30
+    let description = symbol ? symbol.toString() : 'undefined';
31
+
32
+    if (description.startsWith('Symbol(') && description.endsWith(')')) {
33
+        description = description.slice(7, -1);
34
+    }
35
+
36
+    // The polyfill es6-symbol that we use does not appear to comply with the
37
+    // Symbol standard and, merely, adds @@ at the beginning of the description.
38
+    if (description.startsWith('@@')) {
39
+        description = description.slice(2);
40
+    }
41
+
42
+    return description;
43
+}
44
+
22 45
 /**
23 46
  * A helper function that behaves similar to Object.assign, but only reassigns a
24 47
  * property in target if it's defined in source.

+ 6
- 29
react/features/mobile/external-api/middleware.js 查看文件

@@ -17,7 +17,7 @@ import {
17 17
 import { LOAD_CONFIG_ERROR } from '../../base/config';
18 18
 import { CONNECTION_FAILED } from '../../base/connection';
19 19
 import { MiddlewareRegistry } from '../../base/redux';
20
-import { toURLString } from '../../base/util';
20
+import { getSymbolDescription, toURLString } from '../../base/util';
21 21
 import { ENTER_PICTURE_IN_PICTURE } from '../picture-in-picture';
22 22
 
23 23
 /**
@@ -66,7 +66,7 @@ MiddlewareRegistry.register(store => next => action => {
66 66
         break;
67 67
 
68 68
     case ENTER_PICTURE_IN_PICTURE:
69
-        _sendEvent(store, _getSymbolDescription(type), /* data */ {});
69
+        _sendEvent(store, getSymbolDescription(type), /* data */ {});
70 70
         break;
71 71
 
72 72
     case LOAD_CONFIG_ERROR: {
@@ -74,7 +74,7 @@ MiddlewareRegistry.register(store => next => action => {
74 74
 
75 75
         _sendEvent(
76 76
             store,
77
-            _getSymbolDescription(type),
77
+            getSymbolDescription(type),
78 78
             /* data */ {
79 79
                 error: _toErrorString(error),
80 80
                 url: toURLString(locationURL)
@@ -110,29 +110,6 @@ function _toErrorString(
110 110
             : '');
111 111
 }
112 112
 
113
-/**
114
- * Gets the description of a specific {@code Symbol}.
115
- *
116
- * @param {Symbol} symbol - The {@code Symbol} to retrieve the description of.
117
- * @private
118
- * @returns {string} The description of {@code symbol}.
119
- */
120
-function _getSymbolDescription(symbol: Symbol) {
121
-    let description = symbol.toString();
122
-
123
-    if (description.startsWith('Symbol(') && description.endsWith(')')) {
124
-        description = description.slice(7, -1);
125
-    }
126
-
127
-    // The polyfill es6-symbol that we use does not appear to comply with the
128
-    // Symbol standard and, merely, adds @@ at the beginning of the description.
129
-    if (description.startsWith('@@')) {
130
-        description = description.slice(2);
131
-    }
132
-
133
-    return description;
134
-}
135
-
136 113
 /**
137 114
  * If {@link SET_ROOM} action happens for a valid conference room this method
138 115
  * will emit an early {@link CONFERENCE_WILL_JOIN} event to let the external API
@@ -153,7 +130,7 @@ function _maybeTriggerEarlyConferenceWillJoin(store, action) {
153 130
 
154 131
     isRoomValid(room) && locationURL && _sendEvent(
155 132
         store,
156
-        _getSymbolDescription(CONFERENCE_WILL_JOIN),
133
+        getSymbolDescription(CONFERENCE_WILL_JOIN),
157 134
         /* data */ {
158 135
             url: toURLString(locationURL)
159 136
         });
@@ -184,7 +161,7 @@ function _sendConferenceEvent(
184 161
     }
185 162
 
186 163
     _swallowEvent(store, action, data)
187
-        || _sendEvent(store, _getSymbolDescription(type), data);
164
+        || _sendEvent(store, getSymbolDescription(type), data);
188 165
 }
189 166
 
190 167
 /**
@@ -210,7 +187,7 @@ function _sendConferenceFailedOnConnectionError(store, action) {
210 187
             conference => conference.getConnection() !== connection)
211 188
         && _sendEvent(
212 189
         store,
213
-        _getSymbolDescription(CONFERENCE_FAILED),
190
+        getSymbolDescription(CONFERENCE_FAILED),
214 191
         /* data */ {
215 192
             url: toURLString(locationURL),
216 193
             error: action.error.name

正在加载...
取消
保存