Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

ref(api): move local participant name change

Leonard Kim94b3f6410d80
diff --git a/conference.js b/conference.js
index b15e2242cd..d0d31ca7af 100644
--- a/conference.js
+++ b/conference.js
@@ -2753,14 +2753,6 @@ export default {
displayName: formattedNickname
}));
- APP.API.notifyDisplayNameChanged(id, {
- displayName: formattedNickname,
- formattedDisplayName:
- appendSuffix(
- formattedNickname,
- interfaceConfig.DEFAULT_LOCAL_DISPLAY_NAME)
- });
-
if (room) {
APP.UI.changeDisplayName(id, formattedNickname);
}
diff --git a/react/features/display-name/functions.js b/react/features/display-name/functions.js
index d3b661da27..7ffb2d775a 100644
--- a/react/features/display-name/functions.js
+++ b/react/features/display-name/functions.js
@@ -1,3 +1,5 @@
+// @flow
+
/**
* Appends a suffix to the display name.
*
@@ -5,7 +7,7 @@
* @param {string} suffix - Suffix that will be appended.
* @returns {string} The formatted display name.
*/
-export function appendSuffix(displayName, suffix) {
+export function appendSuffix(displayName: string, suffix: string) {
return `${displayName || suffix || ''}${
displayName && suffix && displayName !== suffix ? ` (${suffix})` : ''}`;
}
diff --git a/react/features/external-api/subscriber.js b/react/features/external-api/subscriber.js
index c07ef888c8..755d0d8b1e 100644
--- a/react/features/external-api/subscriber.js
+++ b/react/features/external-api/subscriber.js
@@ -1,9 +1,12 @@
// @flow
+import { getLocalParticipant } from '../base/participants';
import { StateListenerRegistry } from '../base/redux';
+import { appendSuffix } from '../display-name';
import { shouldDisplayTileView } from '../video-layout';
declare var APP: Object;
+declare var interfaceConfig: Object;
/**
* StateListenerRegistry provides a reliable way of detecting changes to
@@ -14,3 +17,23 @@ StateListenerRegistry.register(
/* listener */ displayTileView => {
APP.API.notifyTileViewChanged(displayTileView);
});
+
+StateListenerRegistry.register(
+ /* selector */ state => state['features/base/settings'].displayName,
+ /* listener */ (displayName, store) => {
+ const localParticipant = getLocalParticipant(store.getState());
+
+ // Initial setting of the display name occurs happens on app
+ // initialization, before the local participant is ready. The initial
+ // settings is not desired to be fired anyways, only changes.
+ if (localParticipant) {
+ const { id } = localParticipant;
+
+ APP.API.notifyDisplayNameChanged(id, {
+ displayName,
+ formattedDisplayName: appendSuffix(
+ displayName,
+ interfaceConfig.DEFAULT_LOCAL_DISPLAY_NAME)
+ });
+ }
+ });