Browse Source

ref(api): move conference join notification to middleware

master
Leonard Kim 6 years ago
parent
commit
9d94257e79
2 changed files with 32 additions and 16 deletions
  1. 0
    13
      conference.js
  2. 32
    3
      react/features/external-api/middleware.js

+ 0
- 13
conference.js View File

@@ -79,7 +79,6 @@ import {
79 79
 import { showNotification } from './react/features/notifications';
80 80
 import {
81 81
     dominantSpeakerChanged,
82
-    getAvatarURLByParticipantId,
83 82
     getLocalParticipant,
84 83
     getNormalizedDisplayName,
85 84
     getParticipantById,
@@ -2278,18 +2277,6 @@ export default {
2278 2277
             = APP.store.getState()['features/base/settings'].displayName;
2279 2278
 
2280 2279
         APP.UI.changeDisplayName('localVideoContainer', displayName);
2281
-        APP.API.notifyConferenceJoined(
2282
-            this.roomName,
2283
-            this._room.myUserId(),
2284
-            {
2285
-                displayName,
2286
-                formattedDisplayName: appendSuffix(
2287
-                    displayName,
2288
-                    interfaceConfig.DEFAULT_LOCAL_DISPLAY_NAME),
2289
-                avatarURL: getAvatarURLByParticipantId(
2290
-                    APP.store.getState(), this._room.myUserId())
2291
-            }
2292
-        );
2293 2280
     },
2294 2281
 
2295 2282
     /**

+ 32
- 3
react/features/external-api/middleware.js View File

@@ -1,20 +1,28 @@
1 1
 // @flow
2 2
 
3
-import { CONFERENCE_FAILED } from '../base/conference';
3
+import { CONFERENCE_FAILED, CONFERENCE_JOINED } from '../base/conference';
4 4
 import { NOTIFY_CAMERA_ERROR, NOTIFY_MIC_ERROR } from '../base/devices';
5 5
 import { JitsiConferenceErrors } from '../base/lib-jitsi-meet';
6
+import {
7
+    getAvatarURLByParticipantId,
8
+    getLocalParticipant
9
+} from '../base/participants';
6 10
 import { MiddlewareRegistry } from '../base/redux';
11
+import { appendSuffix } from '../display-name';
7 12
 import { SUBMIT_FEEDBACK } from '../feedback';
8 13
 import { SET_FILMSTRIP_VISIBLE } from '../filmstrip';
9 14
 
10 15
 declare var APP: Object;
16
+declare var interfaceConfig: Object;
11 17
 
12 18
 /**
13 19
  * The middleware of the feature {@code external-api}.
14 20
  *
15 21
  * @returns {Function}
16 22
  */
17
-MiddlewareRegistry.register((/* store */) => next => action => {
23
+MiddlewareRegistry.register(store => next => action => {
24
+    const result = next(action);
25
+
18 26
     switch (action.type) {
19 27
     case CONFERENCE_FAILED: {
20 28
         if (action.conference
@@ -24,6 +32,27 @@ MiddlewareRegistry.register((/* store */) => next => action => {
24 32
         break;
25 33
     }
26 34
 
35
+    case CONFERENCE_JOINED: {
36
+        const state = store.getState();
37
+        const { room } = state['features/base/conference'];
38
+        const { name, id } = getLocalParticipant(state);
39
+
40
+        APP.API.notifyConferenceJoined(
41
+            room,
42
+            id,
43
+            {
44
+                displayName: name,
45
+                formattedDisplayName: appendSuffix(
46
+                    name,
47
+                    interfaceConfig.DEFAULT_LOCAL_DISPLAY_NAME
48
+                ),
49
+                avatarURL: getAvatarURLByParticipantId(state, id)
50
+            }
51
+        );
52
+
53
+        break;
54
+    }
55
+
27 56
     case NOTIFY_CAMERA_ERROR:
28 57
         if (action.error) {
29 58
             APP.API.notifyOnCameraError(
@@ -46,5 +75,5 @@ MiddlewareRegistry.register((/* store */) => next => action => {
46 75
         break;
47 76
     }
48 77
 
49
-    return next(action);
78
+    return result;
50 79
 });

Loading…
Cancel
Save