Explorar el Código

feat(config) defaultLocalDisplayName and defaultRemoteDisplayName

master
Calin Chitu hace 3 años
padre
commit
5c67e8b4ce

+ 5
- 44
conference.js Ver fichero

@@ -86,7 +86,6 @@ import {
86 86
     dominantSpeakerChanged,
87 87
     getLocalParticipant,
88 88
     getNormalizedDisplayName,
89
-    getParticipantById,
90 89
     localParticipantConnectionStatusChanged,
91 90
     localParticipantRoleChanged,
92 91
     participantConnectionStatusChanged,
@@ -235,17 +234,6 @@ function sendData(command, value) {
235 234
     room.sendCommand(command, { value });
236 235
 }
237 236
 
238
-/**
239
- * Get user nickname by user id.
240
- * @param {string} id user id
241
- * @returns {string?} user nickname or undefined if user is unknown.
242
- */
243
-function getDisplayName(id) {
244
-    const participant = getParticipantById(APP.store.getState(), id);
245
-
246
-    return participant && participant.name;
247
-}
248
-
249 237
 /**
250 238
  * Mute or unmute local audio stream if it exists.
251 239
  * @param {boolean} muted - if audio stream should be muted or unmuted.
@@ -1218,14 +1206,6 @@ export default {
1218 1206
         return room.isConnectionInterrupted();
1219 1207
     },
1220 1208
 
1221
-    /**
1222
-     * Obtains the local display name.
1223
-     * @returns {string|undefined}
1224
-     */
1225
-    getLocalDisplayName() {
1226
-        return getDisplayName(this.getMyUserId());
1227
-    },
1228
-
1229 1209
     /**
1230 1210
      * Finds JitsiParticipant for given id.
1231 1211
      *
@@ -1238,29 +1218,6 @@ export default {
1238 1218
         return room ? room.getParticipantById(id) : null;
1239 1219
     },
1240 1220
 
1241
-    /**
1242
-     * Gets the display name foe the <tt>JitsiParticipant</tt> identified by
1243
-     * the given <tt>id</tt>.
1244
-     *
1245
-     * @param id {string} the participant's id(MUC nickname/JVB endpoint id)
1246
-     *
1247
-     * @return {string} the participant's display name or the default string if
1248
-     * absent.
1249
-     */
1250
-    getParticipantDisplayName(id) {
1251
-        const displayName = getDisplayName(id);
1252
-
1253
-        if (displayName) {
1254
-            return displayName;
1255
-        }
1256
-        if (APP.conference.isLocalId(id)) {
1257
-            return APP.translation.generateTranslationHTML(
1258
-                    interfaceConfig.DEFAULT_LOCAL_DISPLAY_NAME);
1259
-        }
1260
-
1261
-        return interfaceConfig.DEFAULT_REMOTE_DISPLAY_NAME;
1262
-    },
1263
-
1264 1221
     getMyUserId() {
1265 1222
         return room && room.myUserId();
1266 1223
     },
@@ -2222,6 +2179,10 @@ export default {
2222 2179
             (id, displayName) => {
2223 2180
                 const formattedDisplayName
2224 2181
                     = getNormalizedDisplayName(displayName);
2182
+                const state = APP.store.getState();
2183
+                const {
2184
+                    defaultRemoteDisplayName
2185
+                } = state['features/base/config'];
2225 2186
 
2226 2187
                 APP.store.dispatch(participantUpdated({
2227 2188
                     conference: room,
@@ -2233,7 +2194,7 @@ export default {
2233 2194
                     formattedDisplayName:
2234 2195
                         appendSuffix(
2235 2196
                             formattedDisplayName
2236
-                                || interfaceConfig.DEFAULT_REMOTE_DISPLAY_NAME)
2197
+                                || defaultRemoteDisplayName)
2237 2198
                 });
2238 2199
             }
2239 2200
         );

+ 6
- 0
config.js Ver fichero

@@ -466,6 +466,12 @@ var config = {
466 466
     // when the toolbar is shown on mouse movements
467 467
     // disable1On1Mode: null | false | true,
468 468
 
469
+    // Default local name to be displayed
470
+    // defaultLocalDisplayName: 'me',
471
+
472
+    // Default remote name to be displayed
473
+    // defaultRemoteDisplayName: 'Fellow Jitster',
474
+
469 475
     // Default language for the user interface.
470 476
     // defaultLanguage: 'en',
471 477
 

+ 6
- 2
interface_config.js Ver fichero

@@ -27,9 +27,7 @@ var interfaceConfig = {
27 27
     CLOSE_PAGE_GUEST_HINT: false, // A html text to be shown to guests on the close page, false disables it
28 28
 
29 29
     DEFAULT_BACKGROUND: '#474747',
30
-    DEFAULT_LOCAL_DISPLAY_NAME: 'me',
31 30
     DEFAULT_LOGO_URL: 'images/watermark.svg',
32
-    DEFAULT_REMOTE_DISPLAY_NAME: 'Fellow Jitster',
33 31
     DEFAULT_WELCOME_PAGE_LOGO_URL: 'images/watermark.svg',
34 32
 
35 33
     DISABLE_DOMINANT_SPEAKER_INDICATOR: false,
@@ -241,6 +239,12 @@ var interfaceConfig = {
241 239
     // Please use disableModeratorIndicator from config.js
242 240
     // DISABLE_FOCUS_INDICATOR: false,
243 241
 
242
+    // Please use defaultLocalDisplayName from config.js
243
+    // DEFAULT_LOCAL_DISPLAY_NAME: 'me',
244
+
245
+    // Please use defaultRemoteDisplayName from config.js
246
+    // DEFAULT_REMOTE_DISPLAY_NAME: 'Fellow Jitster',
247
+
244 248
     // Moved to config.js as `toolbarConfig.initialTimeout`.
245 249
     // INITIAL_TOOLBAR_TIMEOUT: 20000,
246 250
 

+ 7
- 2
modules/UI/videolayout/LargeVideoManager.js Ver fichero

@@ -14,7 +14,10 @@ import {
14 14
     JitsiParticipantConnectionStatus
15 15
 } from '../../../react/features/base/lib-jitsi-meet';
16 16
 import { MEDIA_TYPE, VIDEO_TYPE } from '../../../react/features/base/media';
17
-import { getParticipantById } from '../../../react/features/base/participants';
17
+import {
18
+    getParticipantById,
19
+    getParticipantDisplayName
20
+} from '../../../react/features/base/participants';
18 21
 import { getTrackByMediaTypeAndParticipant } from '../../../react/features/base/tracks';
19 22
 import { CHAT_SIZE } from '../../../react/features/chat';
20 23
 import {
@@ -314,10 +317,12 @@ export default class LargeVideoManager {
314 317
      * @private
315 318
      */
316 319
     updateParticipantConnStatusIndication(id, messageKey) {
320
+        const state = APP.store.getState();
321
+
317 322
         if (messageKey) {
318 323
             // Get user's display name
319 324
             const displayName
320
-                = APP.conference.getParticipantDisplayName(id);
325
+                = getParticipantDisplayName(state, id);
321 326
 
322 327
             this._setRemoteConnectionMessage(
323 328
                 messageKey,

+ 2
- 0
react/features/base/config/configWhitelist.js Ver fichero

@@ -81,6 +81,8 @@ export default [
81 81
     'debug',
82 82
     'debugAudioLevels',
83 83
     'defaultLanguage',
84
+    'defaultLocalDisplayName',
85
+    'defaultRemoteDisplayName',
84 86
     'desktopSharingFrameRate',
85 87
     'desktopSharingSources',
86 88
     'disable1On1Mode',

+ 18
- 0
react/features/base/config/reducer.js Ver fichero

@@ -320,6 +320,24 @@ function _translateLegacyConfig(oldValue: Object) {
320 320
         newValue.e2ee.e2eeLabels = oldValue.e2eeLabels;
321 321
     }
322 322
 
323
+    if (oldValue.defaultLocalDisplayName === undefined
324
+        && typeof interfaceConfig === 'object'
325
+        && interfaceConfig.hasOwnProperty('DEFAULT_LOCAL_DISPLAY_NAME')) {
326
+        newValue.defaultLocalDisplayName = interfaceConfig.DEFAULT_LOCAL_DISPLAY_NAME;
327
+    }
328
+
329
+    newValue.defaultLocalDisplayName
330
+        = newValue.defaultLocalDisplayName || 'me';
331
+
332
+    if (oldValue.defaultRemoteDisplayName === undefined
333
+        && typeof interfaceConfig === 'object'
334
+        && interfaceConfig.hasOwnProperty('DEFAULT_REMOTE_DISPLAY_NAME')) {
335
+        newValue.defaultRemoteDisplayName = interfaceConfig.DEFAULT_REMOTE_DISPLAY_NAME;
336
+    }
337
+
338
+    newValue.defaultRemoteDisplayName
339
+        = newValue.defaultRemoteDisplayName || 'Fellow Jitster';
340
+
323 341
     return newValue;
324 342
 }
325 343
 

+ 6
- 10
react/features/base/participants/functions.js Ver fichero

@@ -16,7 +16,6 @@ import {
16 16
 } from './constants';
17 17
 import { preloadImage } from './preloadImage';
18 18
 
19
-declare var interfaceConfig: Object;
20 19
 
21 20
 /**
22 21
  * Temp structures for avatar urls to be checked/preloaded.
@@ -198,9 +197,6 @@ export function getParticipantCountWithFake(stateful: Object | Function) {
198 197
 /**
199 198
  * Returns participant's display name.
200 199
  *
201
- * FIXME: Remove the hardcoded strings once interfaceConfig is stored in redux
202
- * and merge with a similarly named method in {@code conference.js}.
203
- *
204 200
  * @param {(Function|Object)} stateful - The (whole) redux state, or redux's
205 201
  * {@code getState} function to be used to retrieve the state.
206 202
  * @param {string} id - The ID of the participant's display name to retrieve.
@@ -210,6 +206,10 @@ export function getParticipantDisplayName(
210 206
         stateful: Object | Function,
211 207
         id: string) {
212 208
     const participant = getParticipantById(stateful, id);
209
+    const {
210
+        defaultLocalDisplayName,
211
+        defaultRemoteDisplayName
212
+    } = toState(stateful)['features/base/config'];
213 213
 
214 214
     if (participant) {
215 215
         if (participant.name) {
@@ -217,15 +217,11 @@ export function getParticipantDisplayName(
217 217
         }
218 218
 
219 219
         if (participant.local) {
220
-            return typeof interfaceConfig === 'object'
221
-                ? interfaceConfig.DEFAULT_LOCAL_DISPLAY_NAME
222
-                : 'me';
220
+            return defaultLocalDisplayName;
223 221
         }
224 222
     }
225 223
 
226
-    return typeof interfaceConfig === 'object'
227
-        ? interfaceConfig.DEFAULT_REMOTE_DISPLAY_NAME
228
-        : 'Fellow Jitster';
224
+    return defaultRemoteDisplayName;
229 225
 }
230 226
 
231 227
 /**

+ 12
- 8
react/features/base/participants/reducer.js Ver fichero

@@ -16,8 +16,6 @@ import {
16 16
 import { LOCAL_PARTICIPANT_DEFAULT_ID, PARTICIPANT_ROLE } from './constants';
17 17
 import { isParticipantModerator } from './functions';
18 18
 
19
-declare var interfaceConfig: Object;
20
-
21 19
 /**
22 20
  * Participant object.
23 21
  *
@@ -109,7 +107,10 @@ ReducerRegistry.register('features/base/participants', (state = DEFAULT_STATE, a
109 107
             if (speaker !== local?.id) {
110 108
                 const remoteParticipant = state.remote.get(speaker);
111 109
 
112
-                remoteParticipant && sortedSpeakersList.push([ speaker, _getDisplayName(remoteParticipant.name) ]);
110
+                remoteParticipant
111
+                && sortedSpeakersList.push(
112
+                    [ speaker, _getDisplayName(state, remoteParticipant.name) ]
113
+                );
113 114
             }
114 115
         }
115 116
 
@@ -240,7 +241,7 @@ ReducerRegistry.register('features/base/participants', (state = DEFAULT_STATE, a
240 241
         state.remote.set(id, participant);
241 242
 
242 243
         // Insert the new participant.
243
-        const displayName = _getDisplayName(name);
244
+        const displayName = _getDisplayName(state, name);
244 245
         const sortedRemoteParticipants = Array.from(state.sortedRemoteParticipants);
245 246
 
246 247
         sortedRemoteParticipants.push([ id, displayName ]);
@@ -336,7 +337,8 @@ ReducerRegistry.register('features/base/participants', (state = DEFAULT_STATE, a
336 337
             const remoteParticipant = state.remote.get(participant);
337 338
 
338 339
             if (remoteParticipant) {
339
-                const displayName = _getDisplayName(remoteParticipant.name);
340
+                const displayName
341
+                    = _getDisplayName(state, remoteParticipant.name);
340 342
 
341 343
                 sortedSharesList.push([ participant, displayName ]);
342 344
             }
@@ -356,12 +358,14 @@ ReducerRegistry.register('features/base/participants', (state = DEFAULT_STATE, a
356 358
 /**
357 359
  * Returns the participant's display name, default string if display name is not set on the participant.
358 360
  *
361
+ * @param {Object} state - The local participant redux state.
359 362
  * @param {string} name - The display name of the participant.
360 363
  * @returns {string}
361 364
  */
362
-function _getDisplayName(name) {
363
-    return name
364
-        ?? (typeof interfaceConfig === 'object' ? interfaceConfig.DEFAULT_REMOTE_DISPLAY_NAME : 'Fellow Jitser');
365
+function _getDisplayName(state: Object, name: string): string {
366
+    const config = state['features/base/config'];
367
+
368
+    return name ?? (config?.defaultRemoteDisplayName || 'Fellow Jitster');
365 369
 }
366 370
 
367 371
 /**

+ 5
- 3
react/features/external-api/middleware.js Ver fichero

@@ -27,7 +27,6 @@ import { SET_FILMSTRIP_VISIBLE } from '../filmstrip';
27 27
 import './subscriber';
28 28
 
29 29
 declare var APP: Object;
30
-declare var interfaceConfig: Object;
31 30
 
32 31
 /**
33 32
  * The middleware of the feature {@code external-api}.
@@ -86,6 +85,7 @@ MiddlewareRegistry.register(store => next => action => {
86 85
 
87 86
     case CONFERENCE_JOINED: {
88 87
         const state = store.getState();
88
+        const { defaultLocalDisplayName } = state['features/base/config'];
89 89
         const { room } = state['features/base/conference'];
90 90
         const { loadableAvatarUrl, name, id } = getLocalParticipant(state);
91 91
 
@@ -96,7 +96,7 @@ MiddlewareRegistry.register(store => next => action => {
96 96
                 displayName: name,
97 97
                 formattedDisplayName: appendSuffix(
98 98
                     name,
99
-                    interfaceConfig.DEFAULT_LOCAL_DISPLAY_NAME
99
+                    defaultLocalDisplayName
100 100
                 ),
101 101
                 avatarURL: loadableAvatarUrl
102 102
             }
@@ -149,6 +149,8 @@ MiddlewareRegistry.register(store => next => action => {
149 149
         break;
150 150
 
151 151
     case PARTICIPANT_JOINED: {
152
+        const state = store.getState();
153
+        const { defaultRemoteDisplayName } = state['features/base/config'];
152 154
         const { participant } = action;
153 155
         const { id, local, name } = participant;
154 156
 
@@ -158,7 +160,7 @@ MiddlewareRegistry.register(store => next => action => {
158 160
             APP.API.notifyUserJoined(id, {
159 161
                 displayName: name,
160 162
                 formattedDisplayName: appendSuffix(
161
-                    name || interfaceConfig.DEFAULT_REMOTE_DISPLAY_NAME)
163
+                    name || defaultRemoteDisplayName)
162 164
             });
163 165
         }
164 166
 

+ 3
- 2
react/features/external-api/subscriber.js Ver fichero

@@ -6,7 +6,6 @@ import { appendSuffix } from '../display-name';
6 6
 import { shouldDisplayTileView } from '../video-layout';
7 7
 
8 8
 declare var APP: Object;
9
-declare var interfaceConfig: Object;
10 9
 
11 10
 /**
12 11
  * StateListenerRegistry provides a reliable way of detecting changes to
@@ -22,6 +21,7 @@ StateListenerRegistry.register(
22 21
     /* selector */ state => state['features/base/settings'].displayName,
23 22
     /* listener */ (displayName, store) => {
24 23
         const localParticipant = getLocalParticipant(store.getState());
24
+        const { defaultLocalDisplayName } = store.getState()['features/base/config'];
25 25
 
26 26
         // Initial setting of the display name occurs happens on app
27 27
         // initialization, before the local participant is ready. The initial
@@ -33,7 +33,8 @@ StateListenerRegistry.register(
33 33
                 displayName,
34 34
                 formattedDisplayName: appendSuffix(
35 35
                     displayName,
36
-                    interfaceConfig.DEFAULT_LOCAL_DISPLAY_NAME)
36
+                    defaultLocalDisplayName
37
+                )
37 38
             });
38 39
         }
39 40
     });

+ 2
- 1
react/features/filmstrip/components/web/Thumbnail.js Ver fichero

@@ -1122,6 +1122,7 @@ function _mapStateToProps(state, ownProps): Object {
1122 1122
     let _isMobilePortrait = false;
1123 1123
     const {
1124 1124
         startSilent,
1125
+        defaultLocalDisplayName,
1125 1126
         disableLocalVideoFlip,
1126 1127
         iAmRecorder,
1127 1128
         iAmSipGateway
@@ -1178,7 +1179,7 @@ function _mapStateToProps(state, ownProps): Object {
1178 1179
         _connectionIndicatorDisabled: _isMobile
1179 1180
             || Boolean(state['features/base/config'].connectionIndicators?.disabled),
1180 1181
         _currentLayout,
1181
-        _defaultLocalDisplayName: interfaceConfig.DEFAULT_LOCAL_DISPLAY_NAME,
1182
+        _defaultLocalDisplayName: defaultLocalDisplayName,
1182 1183
         _disableLocalVideoFlip: Boolean(disableLocalVideoFlip),
1183 1184
         _isHidden: isLocal && iAmRecorder && !iAmSipGateway,
1184 1185
         _isAudioOnly: Boolean(state['features/base/audio-only'].enabled),

+ 14
- 3
react/features/toolbox/components/web/ProfileButton.js Ver fichero

@@ -14,6 +14,11 @@ import ProfileButtonAvatar from './ProfileButtonAvatar';
14 14
  */
15 15
 type Props = AbstractButtonProps & {
16 16
 
17
+    /**
18
+     * Default displayed name for local participant.
19
+     */
20
+    _defaultLocalDisplayName: string,
21
+
17 22
     /**
18 23
      * The redux representation of the local participant.
19 24
      */
@@ -43,13 +48,16 @@ class ProfileButton extends AbstractButton<Props, *> {
43 48
      * Retrieves the label.
44 49
      */
45 50
     get label() {
46
-        const { _localParticipant } = this.props;
51
+        const {
52
+            _defaultLocalDisplayName,
53
+            _localParticipant
54
+        } = this.props;
47 55
         let displayName;
48 56
 
49
-        if (_localParticipant && _localParticipant.name) {
57
+        if (_localParticipant?.name) {
50 58
             displayName = _localParticipant.name;
51 59
         } else {
52
-            displayName = interfaceConfig.DEFAULT_LOCAL_DISPLAY_NAME;
60
+            displayName = _defaultLocalDisplayName;
53 61
         }
54 62
 
55 63
         return displayName;
@@ -119,7 +127,10 @@ class ProfileButton extends AbstractButton<Props, *> {
119 127
  * @returns {Object}
120 128
  */
121 129
 const mapStateToProps = state => {
130
+    const { defaultLocalDisplayName } = state['features/base/config'];
131
+
122 132
     return {
133
+        _defaultLocalDisplayName: defaultLocalDisplayName,
123 134
         _localParticipant: getLocalParticipant(state),
124 135
         _unclickable: !interfaceConfig.SETTINGS_SECTIONS.includes('profile'),
125 136
         customClass: 'profile-button-avatar'

Loading…
Cancelar
Guardar