Browse Source

Use Symbol for Redux action types to prevent conflicts

master
Lyubomir Marinov 9 years ago
parent
commit
daf56455a5

+ 4
- 2
react/features/app/actionTypes.js View File

1
+import { Symbol } from '../base/react';
2
+
1
 /**
3
 /**
2
  * The type of the actions which signals that a specific App will mount (in the
4
  * The type of the actions which signals that a specific App will mount (in the
3
  * terms of React).
5
  * terms of React).
7
  *     app: App
9
  *     app: App
8
  * }
10
  * }
9
  */
11
  */
10
-export const APP_WILL_MOUNT = 'APP_WILL_MOUNT';
12
+export const APP_WILL_MOUNT = Symbol('APP_WILL_MOUNT');
11
 
13
 
12
 /**
14
 /**
13
  * The type of the actions which signals that a specific App will unmount (in
15
  * The type of the actions which signals that a specific App will unmount (in
18
  *     app: App
20
  *     app: App
19
  * }
21
  * }
20
  */
22
  */
21
-export const APP_WILL_UNMOUNT = 'APP_WILL_UNMOUNT';
23
+export const APP_WILL_UNMOUNT = Symbol('APP_WILL_UNMOUNT');

+ 6
- 4
react/features/base/conference/actionTypes.js View File

1
+import { Symbol } from '../react';
2
+
1
 /**
3
 /**
2
  * Action type to signal that we are joining the conference.
4
  * Action type to signal that we are joining the conference.
3
  *
5
  *
8
  *      }
10
  *      }
9
  * }
11
  * }
10
  */
12
  */
11
-export const CONFERENCE_JOINED = 'CONFERENCE_JOINED';
13
+export const CONFERENCE_JOINED = Symbol('CONFERENCE_JOINED');
12
 
14
 
13
 /**
15
 /**
14
  * Action type to signal that we have left the conference.
16
  * Action type to signal that we have left the conference.
20
  *      }
22
  *      }
21
  * }
23
  * }
22
  */
24
  */
23
-export const CONFERENCE_LEFT = 'CONFERENCE_LEFT';
25
+export const CONFERENCE_LEFT = Symbol('CONFERENCE_LEFT');
24
 
26
 
25
 /**
27
 /**
26
  * Action type to signal that we will leave the specified conference.
28
  * Action type to signal that we will leave the specified conference.
32
  *      }
34
  *      }
33
  * }
35
  * }
34
  */
36
  */
35
-export const CONFERENCE_WILL_LEAVE = 'CONFERENCE_WILL_LEAVE';
37
+export const CONFERENCE_WILL_LEAVE = Symbol('CONFERENCE_WILL_LEAVE');
36
 
38
 
37
 /**
39
 /**
38
  * The type of the Redux action which sets the name of the room of the
40
  * The type of the Redux action which sets the name of the room of the
43
  *      room: string
45
  *      room: string
44
  * }
46
  * }
45
  */
47
  */
46
-export const SET_ROOM = 'SET_ROOM';
48
+export const SET_ROOM = Symbol('SET_ROOM');

+ 6
- 10
react/features/base/connection/actionTypes.js View File

1
+import { Symbol } from '../react';
2
+
1
 /**
3
 /**
2
  * Action type to signal that connection has disconnected.
4
  * Action type to signal that connection has disconnected.
3
- *
4
- * @type {string}
5
  */
5
  */
6
-export const CONNECTION_DISCONNECTED = 'CONNECTION_DISCONNECTED';
6
+export const CONNECTION_DISCONNECTED = Symbol('CONNECTION_DISCONNECTED');
7
 
7
 
8
 /**
8
 /**
9
  * Action type to signal that have successfully established a connection.
9
  * Action type to signal that have successfully established a connection.
10
- *
11
- * @type {string}
12
  */
10
  */
13
-export const CONNECTION_ESTABLISHED = 'CONNECTION_ESTABLISHED';
11
+export const CONNECTION_ESTABLISHED = Symbol('CONNECTION_ESTABLISHED');
14
 
12
 
15
 /**
13
 /**
16
  * Action type to signal a connection failed.
14
  * Action type to signal a connection failed.
17
- *
18
- * @type {string}
19
  */
15
  */
20
-export const CONNECTION_FAILED = 'CONNECTION_FAILED';
16
+export const CONNECTION_FAILED = Symbol('CONNECTION_FAILED');
21
 
17
 
22
 /**
18
 /**
23
  * Action to signal to change connection domain.
19
  * Action to signal to change connection domain.
27
  *     domain: string
23
  *     domain: string
28
  * }
24
  * }
29
  */
25
  */
30
-export const SET_DOMAIN = 'SET_DOMAIN';
26
+export const SET_DOMAIN = Symbol('SET_DOMAIN');

+ 6
- 4
react/features/base/lib-jitsi-meet/actionTypes.js View File

1
+import { Symbol } from '../react';
2
+
1
 /**
3
 /**
2
  * Action to signal that lib-jitsi-meet library was disposed.
4
  * Action to signal that lib-jitsi-meet library was disposed.
3
  *
5
  *
5
  *     type: LIB_DISPOSED
7
  *     type: LIB_DISPOSED
6
  * }
8
  * }
7
  */
9
  */
8
-export const LIB_DISPOSED = 'LIB_DISPOSED';
10
+export const LIB_DISPOSED = Symbol('LIB_DISPOSED');
9
 
11
 
10
 /**
12
 /**
11
  * Action to signal that lib-jitsi-meet initialized failed with error.
13
  * Action to signal that lib-jitsi-meet initialized failed with error.
15
  *     error: Error
17
  *     error: Error
16
  * }
18
  * }
17
  */
19
  */
18
-export const LIB_INIT_ERROR = 'LIB_INIT_ERROR';
20
+export const LIB_INIT_ERROR = Symbol('LIB_INIT_ERROR');
19
 
21
 
20
 /**
22
 /**
21
  * Action to signal that lib-jitsi-meet initialization succeeded.
23
  * Action to signal that lib-jitsi-meet initialization succeeded.
24
  *     type: LIB_INITIALIZED
26
  *     type: LIB_INITIALIZED
25
  * }
27
  * }
26
  */
28
  */
27
-export const LIB_INITIALIZED = 'LIB_INITIALIZED';
29
+export const LIB_INITIALIZED = Symbol('LIB_INITIALIZED');
28
 
30
 
29
 /**
31
 /**
30
  * Action to signal that config was set.
32
  * Action to signal that config was set.
34
  *     config: Object
36
  *     config: Object
35
  * }
37
  * }
36
  */
38
  */
37
-export const SET_CONFIG = 'SET_CONFIG';
39
+export const SET_CONFIG = Symbol('SET_CONFIG');

+ 27
- 27
react/features/base/lib-jitsi-meet/native/polyfills-browser.js View File

85
 
85
 
86
 (global => {
86
 (global => {
87
 
87
 
88
+    // Polyfill for URL constructor
89
+    require('url-polyfill');
90
+
88
     const DOMParser = require('xmldom').DOMParser;
91
     const DOMParser = require('xmldom').DOMParser;
89
 
92
 
90
     // addEventListener
93
     // addEventListener
210
         };
213
         };
211
     }
214
     }
212
 
215
 
213
-    // performance
214
-    if (typeof global.performance === 'undefined') {
215
-        global.performance = {
216
-            now() {
217
-                return 0;
218
-            }
219
-        };
220
-    }
221
-
222
-    // sessionStorage
223
-    //
224
-    // Required by:
225
-    // - Strophe
226
-    if (typeof global.sessionStorage === 'undefined') {
227
-        global.sessionStorage = {
228
-            /* eslint-disable no-empty-function */
229
-            getItem() {},
230
-            removeItem() {},
231
-            setItem() {}
232
-
233
-            /* eslint-enable no-empty-function */
234
-        };
235
-    }
236
-
237
     const navigator = global.navigator;
216
     const navigator = global.navigator;
238
 
217
 
239
     if (navigator) {
218
     if (navigator) {
280
         })();
259
         })();
281
     }
260
     }
282
 
261
 
262
+    // performance
263
+    if (typeof global.performance === 'undefined') {
264
+        global.performance = {
265
+            now() {
266
+                return 0;
267
+            }
268
+        };
269
+    }
270
+
271
+    // sessionStorage
272
+    //
273
+    // Required by:
274
+    // - Strophe
275
+    if (typeof global.sessionStorage === 'undefined') {
276
+        global.sessionStorage = {
277
+            /* eslint-disable no-empty-function */
278
+            getItem() {},
279
+            removeItem() {},
280
+            setItem() {}
281
+
282
+            /* eslint-enable no-empty-function */
283
+        };
284
+    }
285
+
283
     // WebRTC
286
     // WebRTC
284
     require('./polyfills-webrtc');
287
     require('./polyfills-webrtc');
285
 
288
 
310
         }
313
         }
311
     }
314
     }
312
 
315
 
313
-    // Polyfill for URL constructor
314
-    require('url-polyfill');
315
-
316
 })(global || window || this); // eslint-disable-line no-invalid-this
316
 })(global || window || this); // eslint-disable-line no-invalid-this

+ 5
- 3
react/features/base/media/actionTypes.js View File

1
+import { Symbol } from '../react';
2
+
1
 /**
3
 /**
2
  * Action to change muted state of the local audio.
4
  * Action to change muted state of the local audio.
3
  *
5
  *
6
  *      muted: boolean
8
  *      muted: boolean
7
  * }
9
  * }
8
  */
10
  */
9
-export const AUDIO_MUTED_CHANGED = 'AUDIO_MUTED_CHANGED';
11
+export const AUDIO_MUTED_CHANGED = Symbol('AUDIO_MUTED_CHANGED');
10
 
12
 
11
 /**
13
 /**
12
  * Action to signal a change of the facing mode of the local video camera.
14
  * Action to signal a change of the facing mode of the local video camera.
16
  *      cameraFacingMode: CAMERA_FACING_MODE
18
  *      cameraFacingMode: CAMERA_FACING_MODE
17
  * }
19
  * }
18
  */
20
  */
19
-export const CAMERA_FACING_MODE_CHANGED = 'CAMERA_FACING_MODE_CHANGED';
21
+export const CAMERA_FACING_MODE_CHANGED = Symbol('CAMERA_FACING_MODE_CHANGED');
20
 
22
 
21
 /**
23
 /**
22
  * Action to change muted state of the local video.
24
  * Action to change muted state of the local video.
26
  *      muted: boolean
28
  *      muted: boolean
27
  * }
29
  * }
28
  */
30
  */
29
-export const VIDEO_MUTED_CHANGED = 'VIDEO_MUTED_CHANGED';
31
+export const VIDEO_MUTED_CHANGED = Symbol('VIDEO_MUTED_CHANGED');

+ 8
- 6
react/features/base/participants/actionTypes.js View File

1
+import { Symbol } from '../react';
2
+
1
 /**
3
 /**
2
  * Create an action for when dominant speaker changes.
4
  * Create an action for when dominant speaker changes.
3
  *
5
  *
8
  *      }
10
  *      }
9
  * }
11
  * }
10
  */
12
  */
11
-export const DOMINANT_SPEAKER_CHANGED = 'DOMINANT_SPEAKER_CHANGED';
13
+export const DOMINANT_SPEAKER_CHANGED = Symbol('DOMINANT_SPEAKER_CHANGED');
12
 
14
 
13
 /**
15
 /**
14
  * Action to signal that ID of participant has changed. This happens when
16
  * Action to signal that ID of participant has changed. This happens when
20
  *      oldValue: string
22
  *      oldValue: string
21
  * }
23
  * }
22
  */
24
  */
23
-export const PARTICIPANT_ID_CHANGED = 'PARTICIPANT_ID_CHANGED';
25
+export const PARTICIPANT_ID_CHANGED = Symbol('PARTICIPANT_ID_CHANGED');
24
 
26
 
25
 /**
27
 /**
26
  * Action to signal that a participant has joined.
28
  * Action to signal that a participant has joined.
30
  *      participant: Participant
32
  *      participant: Participant
31
  * }
33
  * }
32
  */
34
  */
33
-export const PARTICIPANT_JOINED = 'PARTICIPANT_JOINED';
35
+export const PARTICIPANT_JOINED = Symbol('PARTICIPANT_JOINED');
34
 
36
 
35
 /**
37
 /**
36
  * Action to handle case when participant lefts.
38
  * Action to handle case when participant lefts.
42
  *      }
44
  *      }
43
  * }
45
  * }
44
  */
46
  */
45
-export const PARTICIPANT_LEFT = 'PARTICIPANT_LEFT';
47
+export const PARTICIPANT_LEFT = Symbol('PARTICIPANT_LEFT');
46
 
48
 
47
 /**
49
 /**
48
  * Action to handle case when info about participant changes.
50
  * Action to handle case when info about participant changes.
52
  *      participant: Participant
54
  *      participant: Participant
53
  * }
55
  * }
54
  */
56
  */
55
-export const PARTICIPANT_UPDATED = 'PARTICIPANT_UPDATED';
57
+export const PARTICIPANT_UPDATED = Symbol('PARTICIPANT_UPDATED');
56
 
58
 
57
 /**
59
 /**
58
  * The type of the Redux action which pins a conference participant.
60
  * The type of the Redux action which pins a conference participant.
64
  *      }
66
  *      }
65
  * }
67
  * }
66
  */
68
  */
67
-export const PIN_PARTICIPANT = 'PIN_PARTICIPANT';
69
+export const PIN_PARTICIPANT = Symbol('PIN_PARTICIPANT');

+ 14
- 0
react/features/base/react/Symbol.js View File

1
+// FIXME React Native does not polyfill Symbol at versions 0.39.2 or earlier.
2
+export default (global => {
3
+    let s = global.Symbol;
4
+
5
+    if (typeof s === 'undefined') {
6
+        // XXX At the time of this writing we use Symbol only as a way to
7
+        // prevent collisions in Redux action types. Consequently, the Symbol
8
+        // implementation provided bellow is minimal and specific to our
9
+        // purpose.
10
+        s = description => (description || '').split('');
11
+    }
12
+
13
+    return s;
14
+})(global || window || this); // eslint-disable-line no-invalid-this

+ 0
- 0
react/features/base/react/components/Container.web.js View File


+ 0
- 0
react/features/base/react/components/Link.web.js View File


+ 1
- 0
react/features/base/react/index.js View File

1
 export * from './components';
1
 export * from './components';
2
 export * from './functions';
2
 export * from './functions';
3
+export { default as Symbol } from './Symbol';

+ 5
- 3
react/features/base/tracks/actionTypes.js View File

1
+import { Symbol } from '../react';
2
+
1
 /**
3
 /**
2
  * Action for when a track has been added to the conference,
4
  * Action for when a track has been added to the conference,
3
  * local or remote.
5
  * local or remote.
7
  *     track: Track
9
  *     track: Track
8
  * }
10
  * }
9
  */
11
  */
10
-export const TRACK_ADDED = 'TRACK_ADDED';
12
+export const TRACK_ADDED = Symbol('TRACK_ADDED');
11
 
13
 
12
 /**
14
 /**
13
  * Action for when a track has been removed from the conference,
15
  * Action for when a track has been removed from the conference,
18
  *     track: Track
20
  *     track: Track
19
  * }
21
  * }
20
  */
22
  */
21
-export const TRACK_REMOVED = 'TRACK_REMOVED';
23
+export const TRACK_REMOVED = Symbol('TRACK_REMOVED');
22
 
24
 
23
 /**
25
 /**
24
  * Action for when a track properties were updated.
26
  * Action for when a track properties were updated.
28
  *     track: Track
30
  *     track: Track
29
  * }
31
  * }
30
  */
32
  */
31
-export const TRACK_UPDATED = 'TRACK_UPDATED';
33
+export const TRACK_UPDATED = Symbol('TRACK_UPDATED');

+ 0
- 22
react/features/conference/components/ParticipantView.web.js View File

1
-import { Component } from 'react';
2
-
3
-/**
4
- * Implements a React Component which depicts a specific participant's avatar
5
- * and video.
6
- */
7
-export default class ParticipantView extends Component {
8
-
9
-   /**
10
-    * Implements React's {@link Component#render()}.
11
-    *
12
-    * @inheritdoc
13
-    * @returns {ReactElement|null}
14
-    */
15
-    render() {
16
-        // FIXME ParticipantView is supposed to be platform-independent.
17
-        // Temporarily though, ParticipantView is not in use on Web but has to
18
-        // exist in order to split App, Conference, and WelcomePage out of
19
-        // index.html.
20
-        return null;
21
-    }
22
- }

+ 3
- 1
react/features/largeVideo/actionTypes.js View File

1
+import { Symbol } from '../base/react';
2
+
1
 /**
3
 /**
2
  * Action to change the participant to be displayed in LargeVideo.
4
  * Action to change the participant to be displayed in LargeVideo.
3
  *
5
  *
7
  * }
9
  * }
8
  */
10
  */
9
 export const LARGE_VIDEO_PARTICIPANT_CHANGED
11
 export const LARGE_VIDEO_PARTICIPANT_CHANGED
10
-    = 'LARGE_VIDEO_PARTICIPANT_CHANGED';
12
+    = Symbol('LARGE_VIDEO_PARTICIPANT_CHANGED');

Loading…
Cancel
Save