浏览代码

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
     return window.JitsiMeetJS.app;
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
  * A helper function that behaves similar to Object.assign, but only reassigns a
46
  * A helper function that behaves similar to Object.assign, but only reassigns a
24
  * property in target if it's defined in source.
47
  * property in target if it's defined in source.

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

17
 import { LOAD_CONFIG_ERROR } from '../../base/config';
17
 import { LOAD_CONFIG_ERROR } from '../../base/config';
18
 import { CONNECTION_FAILED } from '../../base/connection';
18
 import { CONNECTION_FAILED } from '../../base/connection';
19
 import { MiddlewareRegistry } from '../../base/redux';
19
 import { MiddlewareRegistry } from '../../base/redux';
20
-import { toURLString } from '../../base/util';
20
+import { getSymbolDescription, toURLString } from '../../base/util';
21
 import { ENTER_PICTURE_IN_PICTURE } from '../picture-in-picture';
21
 import { ENTER_PICTURE_IN_PICTURE } from '../picture-in-picture';
22
 
22
 
23
 /**
23
 /**
66
         break;
66
         break;
67
 
67
 
68
     case ENTER_PICTURE_IN_PICTURE:
68
     case ENTER_PICTURE_IN_PICTURE:
69
-        _sendEvent(store, _getSymbolDescription(type), /* data */ {});
69
+        _sendEvent(store, getSymbolDescription(type), /* data */ {});
70
         break;
70
         break;
71
 
71
 
72
     case LOAD_CONFIG_ERROR: {
72
     case LOAD_CONFIG_ERROR: {
74
 
74
 
75
         _sendEvent(
75
         _sendEvent(
76
             store,
76
             store,
77
-            _getSymbolDescription(type),
77
+            getSymbolDescription(type),
78
             /* data */ {
78
             /* data */ {
79
                 error: _toErrorString(error),
79
                 error: _toErrorString(error),
80
                 url: toURLString(locationURL)
80
                 url: toURLString(locationURL)
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
  * If {@link SET_ROOM} action happens for a valid conference room this method
114
  * If {@link SET_ROOM} action happens for a valid conference room this method
138
  * will emit an early {@link CONFERENCE_WILL_JOIN} event to let the external API
115
  * will emit an early {@link CONFERENCE_WILL_JOIN} event to let the external API
153
 
130
 
154
     isRoomValid(room) && locationURL && _sendEvent(
131
     isRoomValid(room) && locationURL && _sendEvent(
155
         store,
132
         store,
156
-        _getSymbolDescription(CONFERENCE_WILL_JOIN),
133
+        getSymbolDescription(CONFERENCE_WILL_JOIN),
157
         /* data */ {
134
         /* data */ {
158
             url: toURLString(locationURL)
135
             url: toURLString(locationURL)
159
         });
136
         });
184
     }
161
     }
185
 
162
 
186
     _swallowEvent(store, action, data)
163
     _swallowEvent(store, action, data)
187
-        || _sendEvent(store, _getSymbolDescription(type), data);
164
+        || _sendEvent(store, getSymbolDescription(type), data);
188
 }
165
 }
189
 
166
 
190
 /**
167
 /**
210
             conference => conference.getConnection() !== connection)
187
             conference => conference.getConnection() !== connection)
211
         && _sendEvent(
188
         && _sendEvent(
212
         store,
189
         store,
213
-        _getSymbolDescription(CONFERENCE_FAILED),
190
+        getSymbolDescription(CONFERENCE_FAILED),
214
         /* data */ {
191
         /* data */ {
215
             url: toURLString(locationURL),
192
             url: toURLString(locationURL),
216
             error: action.error.name
193
             error: action.error.name

正在加载...
取消
保存