浏览代码

fix(display-name): do not default name to placeholder name (#4027)

* ref(display-name): do not pass in display name

The component gets the state itself from redux.

* fix(display-name): do not default name to placeholder name

The web display name component supports inline editing of
the name. Problems can occur when the displayed name
differs from the actual saved name, because participants
without a display name, including the local user, have
a different, default display name displayed. So when
editing starts, the input field is populated with the
default name. To workaround such while supporting fetching
the display name using mapStateToProps, pass in both the
name which should be shown and the name value saved in
settings.

* ref(display-name): rename methods
master
virtuacoplenny 6 年前
父节点
当前提交
d7e112aaf0
没有帐户链接到提交者的电子邮件

+ 6
- 5
modules/UI/shared_video/SharedVideoThumb.js 查看文件

19
     this.bindHoverHandler();
19
     this.bindHoverHandler();
20
     SmallVideo.call(this, VideoLayout);
20
     SmallVideo.call(this, VideoLayout);
21
     this.isVideoMuted = true;
21
     this.isVideoMuted = true;
22
-    this.setDisplayName(participant.name);
22
+    this.updateDisplayName();
23
 
23
 
24
     this.container.onclick = this._onContainerClick;
24
     this.container.onclick = this._onContainerClick;
25
     this.container.ondblclick = this._onContainerDoubleClick;
25
     this.container.ondblclick = this._onContainerDoubleClick;
65
 };
65
 };
66
 
66
 
67
 /**
67
 /**
68
- * Sets the display name for the thumb.
68
+ * Triggers re-rendering of the display name using current instance state.
69
+ *
70
+ * @returns {void}
69
  */
71
  */
70
-SharedVideoThumb.prototype.setDisplayName = function(displayName) {
72
+SharedVideoThumb.prototype.updateDisplayName = function() {
71
     if (!this.container) {
73
     if (!this.container) {
72
         logger.warn(`Unable to set displayName - ${this.videoSpanId
74
         logger.warn(`Unable to set displayName - ${this.videoSpanId
73
         } does not exist`);
75
         } does not exist`);
75
         return;
77
         return;
76
     }
78
     }
77
 
79
 
78
-    this.updateDisplayName({
79
-        displayName: displayName || '',
80
+    this._renderDisplayName({
80
         elementID: `${this.videoSpanId}_name`,
81
         elementID: `${this.videoSpanId}_name`,
81
         participantID: this.id
82
         participantID: this.id
82
     });
83
     });

+ 6
- 5
modules/UI/videolayout/LocalVideo.js 查看文件

50
     SmallVideo.call(this, VideoLayout);
50
     SmallVideo.call(this, VideoLayout);
51
 
51
 
52
     // Set default display name.
52
     // Set default display name.
53
-    this.setDisplayName();
53
+    this.updateDisplayName();
54
 
54
 
55
     // Initialize the avatar display with an avatar url selected from the redux
55
     // Initialize the avatar display with an avatar url selected from the redux
56
     // state. Redux stores the local user with a hardcoded participant id of
56
     // state. Redux stores the local user with a hardcoded participant id of
87
 };
87
 };
88
 
88
 
89
 /**
89
 /**
90
- * Sets the display name for the given video span id.
90
+ * Triggers re-rendering of the display name using current instance state.
91
+ *
92
+ * @returns {void}
91
  */
93
  */
92
-LocalVideo.prototype.setDisplayName = function(displayName) {
94
+LocalVideo.prototype.updateDisplayName = function() {
93
     if (!this.container) {
95
     if (!this.container) {
94
         logger.warn(
96
         logger.warn(
95
                 `Unable to set displayName - ${this.videoSpanId
97
                 `Unable to set displayName - ${this.videoSpanId
98
         return;
100
         return;
99
     }
101
     }
100
 
102
 
101
-    this.updateDisplayName({
103
+    this._renderDisplayName({
102
         allowEditing: APP.store.getState()['features/base/jwt'].isGuest,
104
         allowEditing: APP.store.getState()['features/base/jwt'].isGuest,
103
-        displayName,
104
         displayNameSuffix: interfaceConfig.DEFAULT_LOCAL_DISPLAY_NAME,
105
         displayNameSuffix: interfaceConfig.DEFAULT_LOCAL_DISPLAY_NAME,
105
         elementID: 'localDisplayName',
106
         elementID: 'localDisplayName',
106
         participantID: this.id
107
         participantID: this.id

+ 5
- 6
modules/UI/videolayout/RemoteVideo.js 查看文件

53
         ? 'left bottom' : 'top center';
53
         ? 'left bottom' : 'top center';
54
     this.addRemoteVideoContainer();
54
     this.addRemoteVideoContainer();
55
     this.updateIndicators();
55
     this.updateIndicators();
56
-    this.setDisplayName();
56
+    this.updateDisplayName();
57
     this.bindHoverHandler();
57
     this.bindHoverHandler();
58
     this.flipX = false;
58
     this.flipX = false;
59
     this.isLocal = false;
59
     this.isLocal = false;
519
 };
519
 };
520
 
520
 
521
 /**
521
 /**
522
- * Sets the display name for the given video span id.
522
+ * Triggers re-rendering of the display name using current instance state.
523
  *
523
  *
524
- * @param displayName the display name to set
524
+ * @returns {void}
525
  */
525
  */
526
-RemoteVideo.prototype.setDisplayName = function(displayName) {
526
+RemoteVideo.prototype.updateDisplayName = function() {
527
     if (!this.container) {
527
     if (!this.container) {
528
         logger.warn(`Unable to set displayName - ${this.videoSpanId
528
         logger.warn(`Unable to set displayName - ${this.videoSpanId
529
         } does not exist`);
529
         } does not exist`);
531
         return;
531
         return;
532
     }
532
     }
533
 
533
 
534
-    this.updateDisplayName({
535
-        displayName: displayName || interfaceConfig.DEFAULT_REMOTE_DISPLAY_NAME,
534
+    this._renderDisplayName({
536
         elementID: `${this.videoSpanId}_name`,
535
         elementID: `${this.videoSpanId}_name`,
537
         participantID: this.id
536
         participantID: this.id
538
     });
537
     });

+ 3
- 1
modules/UI/videolayout/SmallVideo.js 查看文件

439
  * Creates or updates the participant's display name that is shown over the
439
  * Creates or updates the participant's display name that is shown over the
440
  * video preview.
440
  * video preview.
441
  *
441
  *
442
+ * @param {Object} props - The React {@code Component} props to pass into the
443
+ * {@code DisplayName} component.
442
  * @returns {void}
444
  * @returns {void}
443
  */
445
  */
444
-SmallVideo.prototype.updateDisplayName = function(props) {
446
+SmallVideo.prototype._renderDisplayName = function(props) {
445
     const displayNameContainer
447
     const displayNameContainer
446
         = this.container.querySelector('.displayNameContainer');
448
         = this.container.querySelector('.displayNameContainer');
447
 
449
 

+ 3
- 3
modules/UI/videolayout/VideoLayout.js 查看文件

659
     /**
659
     /**
660
      * Display name changed.
660
      * Display name changed.
661
      */
661
      */
662
-    onDisplayNameChanged(id, displayName, status) {
662
+    onDisplayNameChanged(id) {
663
         if (id === 'localVideoContainer'
663
         if (id === 'localVideoContainer'
664
             || APP.conference.isLocalId(id)) {
664
             || APP.conference.isLocalId(id)) {
665
-            localVideoThumbnail.setDisplayName(displayName);
665
+            localVideoThumbnail.updateDisplayName();
666
         } else {
666
         } else {
667
             const remoteVideo = remoteVideos[id];
667
             const remoteVideo = remoteVideos[id];
668
 
668
 
669
             if (remoteVideo) {
669
             if (remoteVideo) {
670
-                remoteVideo.setDisplayName(displayName, status);
670
+                remoteVideo.updateDisplayName();
671
             }
671
             }
672
         }
672
         }
673
     },
673
     },

+ 22
- 8
react/features/display-name/components/DisplayName.web.js 查看文件

8
 
8
 
9
 import { translate } from '../../base/i18n';
9
 import { translate } from '../../base/i18n';
10
 import {
10
 import {
11
-    getParticipantDisplayName
11
+    getParticipantDisplayName,
12
+    getParticipantById
12
 } from '../../base/participants';
13
 } from '../../base/participants';
13
 import { updateSettings } from '../../base/settings';
14
 import { updateSettings } from '../../base/settings';
14
 
15
 
18
 type Props = {
19
 type Props = {
19
 
20
 
20
     /**
21
     /**
21
-     * The participant's current display name.
22
+     * The participant's current display name which should be shown when in
23
+     * edit mode. Can be different from what is shown when not editing.
22
      */
24
      */
23
-    _displayName: string,
25
+    _configuredDisplayName: string,
26
+
27
+    /**
28
+     * The participant's current display name which should be shown.
29
+     */
30
+    _nameToDisplay: string,
24
 
31
 
25
     /**
32
     /**
26
      * Whether or not the display name should be editable on click.
33
      * Whether or not the display name should be editable on click.
78
 class DisplayName extends Component<Props, State> {
85
 class DisplayName extends Component<Props, State> {
79
     _nameInput: ?HTMLInputElement;
86
     _nameInput: ?HTMLInputElement;
80
 
87
 
88
+    static defaultProps = {
89
+        _configuredDisplayName: ''
90
+    };
91
+
81
     /**
92
     /**
82
      * Initializes a new {@code DisplayName} instance.
93
      * Initializes a new {@code DisplayName} instance.
83
      *
94
      *
134
      */
145
      */
135
     render() {
146
     render() {
136
         const {
147
         const {
137
-            _displayName,
148
+            _nameToDisplay,
138
             allowEditing,
149
             allowEditing,
139
             displayNameSuffix,
150
             displayNameSuffix,
140
             elementID,
151
             elementID,
163
                 className = 'displayname'
174
                 className = 'displayname'
164
                 id = { elementID }
175
                 id = { elementID }
165
                 onClick = { this._onStartEditing }>
176
                 onClick = { this._onStartEditing }>
166
-                { appendSuffix(_displayName, displayNameSuffix) }
177
+                { appendSuffix(_nameToDisplay, displayNameSuffix) }
167
             </span>
178
             </span>
168
         );
179
         );
169
     }
180
     }
212
         if (this.props.allowEditing) {
223
         if (this.props.allowEditing) {
213
             this.setState({
224
             this.setState({
214
                 isEditing: true,
225
                 isEditing: true,
215
-                editDisplayNameValue: this.props._displayName || ''
226
+                editDisplayNameValue: this.props._configuredDisplayName
216
             });
227
             });
217
         }
228
         }
218
     }
229
     }
268
  * @param {Props} ownProps - The own props of the component.
279
  * @param {Props} ownProps - The own props of the component.
269
  * @private
280
  * @private
270
  * @returns {{
281
  * @returns {{
271
- *     _displayName: string
282
+ *     _configuredDisplayName: string,
283
+ *     _nameToDisplay: string
272
  * }}
284
  * }}
273
  */
285
  */
274
 function _mapStateToProps(state, ownProps) {
286
 function _mapStateToProps(state, ownProps) {
275
     const { participantID } = ownProps;
287
     const { participantID } = ownProps;
288
+    const participant = getParticipantById(state, participantID);
276
 
289
 
277
     return {
290
     return {
278
-        _displayName: getParticipantDisplayName(
291
+        _configuredDisplayName: participant && participant.name,
292
+        _nameToDisplay: getParticipantDisplayName(
279
             state, participantID)
293
             state, participantID)
280
     };
294
     };
281
 }
295
 }

正在加载...
取消
保存