Переглянути джерело

ref(api): move participant join and left to middleware (#4365)

j8
virtuacoplenny 5 роки тому
джерело
коміт
2f626ea474
Аккаунт користувача з таким Email не знайдено

+ 1
- 8
conference.js Переглянути файл

@@ -1713,14 +1713,7 @@ export default {
1713 1713
                 return;
1714 1714
             }
1715 1715
 
1716
-            const displayName = user.getDisplayName();
1717
-
1718 1716
             logger.log(`USER ${id} connnected:`, user);
1719
-            APP.API.notifyUserJoined(id, {
1720
-                displayName,
1721
-                formattedDisplayName: appendSuffix(
1722
-                    displayName || interfaceConfig.DEFAULT_REMOTE_DISPLAY_NAME)
1723
-            });
1724 1717
             APP.UI.addUser(user);
1725 1718
 
1726 1719
             // check the roles for the new user and reflect them
@@ -1736,7 +1729,7 @@ export default {
1736 1729
             }
1737 1730
 
1738 1731
             logger.log(`USER ${id} LEFT:`, user);
1739
-            APP.API.notifyUserLeft(id);
1732
+
1740 1733
             APP.UI.onSharedVideoStop(id);
1741 1734
         });
1742 1735
 

+ 2
- 2
react/features/display-name/functions.js Переглянути файл

@@ -7,7 +7,7 @@
7 7
  * @param {string} suffix - Suffix that will be appended.
8 8
  * @returns {string} The formatted display name.
9 9
  */
10
-export function appendSuffix(displayName: string, suffix: string) {
11
-    return `${displayName || suffix || ''}${
10
+export function appendSuffix(displayName: string, suffix: string = '') {
11
+    return `${displayName || suffix}${
12 12
         displayName && suffix && displayName !== suffix ? ` (${suffix})` : ''}`;
13 13
 }

+ 23
- 0
react/features/external-api/middleware.js Переглянути файл

@@ -9,6 +9,8 @@ import { NOTIFY_CAMERA_ERROR, NOTIFY_MIC_ERROR } from '../base/devices';
9 9
 import { JitsiConferenceErrors } from '../base/lib-jitsi-meet';
10 10
 import {
11 11
     PARTICIPANT_KICKED,
12
+    PARTICIPANT_LEFT,
13
+    PARTICIPANT_JOINED,
12 14
     SET_LOADABLE_AVATAR_URL,
13 15
     getLocalParticipant,
14 16
     getParticipantById
@@ -129,6 +131,27 @@ MiddlewareRegistry.register(store => next => action => {
129 131
             { id: action.kicker });
130 132
         break;
131 133
 
134
+    case PARTICIPANT_LEFT:
135
+        APP.API.notifyUserLeft(action.participant.id);
136
+        break;
137
+
138
+    case PARTICIPANT_JOINED: {
139
+        const { participant } = action;
140
+        const { id, local, name } = participant;
141
+
142
+        // The version of external api outside of middleware did not emit
143
+        // the local participant being created.
144
+        if (!local) {
145
+            APP.API.notifyUserJoined(id, {
146
+                displayName: name,
147
+                formattedDisplayName: appendSuffix(
148
+                    name || interfaceConfig.DEFAULT_REMOTE_DISPLAY_NAME)
149
+            });
150
+        }
151
+
152
+        break;
153
+    }
154
+
132 155
     case SET_FILMSTRIP_VISIBLE:
133 156
         APP.API.notifyFilmstripDisplayChanged(action.visible);
134 157
         break;

Завантаження…
Відмінити
Зберегти