ソースを参照

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,7 +19,7 @@ export default function SharedVideoThumb(participant, videoType, VideoLayout) {
19 19
     this.bindHoverHandler();
20 20
     SmallVideo.call(this, VideoLayout);
21 21
     this.isVideoMuted = true;
22
-    this.setDisplayName(participant.name);
22
+    this.updateDisplayName();
23 23
 
24 24
     this.container.onclick = this._onContainerClick;
25 25
     this.container.ondblclick = this._onContainerDoubleClick;
@@ -65,9 +65,11 @@ SharedVideoThumb.prototype.createContainer = function(spanId) {
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 73
     if (!this.container) {
72 74
         logger.warn(`Unable to set displayName - ${this.videoSpanId
73 75
         } does not exist`);
@@ -75,8 +77,7 @@ SharedVideoThumb.prototype.setDisplayName = function(displayName) {
75 77
         return;
76 78
     }
77 79
 
78
-    this.updateDisplayName({
79
-        displayName: displayName || '',
80
+    this._renderDisplayName({
80 81
         elementID: `${this.videoSpanId}_name`,
81 82
         participantID: this.id
82 83
     });

+ 6
- 5
modules/UI/videolayout/LocalVideo.js ファイルの表示

@@ -50,7 +50,7 @@ function LocalVideo(VideoLayout, emitter, streamEndedCallback) {
50 50
     SmallVideo.call(this, VideoLayout);
51 51
 
52 52
     // Set default display name.
53
-    this.setDisplayName();
53
+    this.updateDisplayName();
54 54
 
55 55
     // Initialize the avatar display with an avatar url selected from the redux
56 56
     // state. Redux stores the local user with a hardcoded participant id of
@@ -87,9 +87,11 @@ LocalVideo.prototype.createContainer = function() {
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 95
     if (!this.container) {
94 96
         logger.warn(
95 97
                 `Unable to set displayName - ${this.videoSpanId
@@ -98,9 +100,8 @@ LocalVideo.prototype.setDisplayName = function(displayName) {
98 100
         return;
99 101
     }
100 102
 
101
-    this.updateDisplayName({
103
+    this._renderDisplayName({
102 104
         allowEditing: APP.store.getState()['features/base/jwt'].isGuest,
103
-        displayName,
104 105
         displayNameSuffix: interfaceConfig.DEFAULT_LOCAL_DISPLAY_NAME,
105 106
         elementID: 'localDisplayName',
106 107
         participantID: this.id

+ 5
- 6
modules/UI/videolayout/RemoteVideo.js ファイルの表示

@@ -53,7 +53,7 @@ function RemoteVideo(user, VideoLayout, emitter) {
53 53
         ? 'left bottom' : 'top center';
54 54
     this.addRemoteVideoContainer();
55 55
     this.updateIndicators();
56
-    this.setDisplayName();
56
+    this.updateDisplayName();
57 57
     this.bindHoverHandler();
58 58
     this.flipX = false;
59 59
     this.isLocal = false;
@@ -519,11 +519,11 @@ RemoteVideo.prototype.addRemoteStreamElement = function(stream) {
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 527
     if (!this.container) {
528 528
         logger.warn(`Unable to set displayName - ${this.videoSpanId
529 529
         } does not exist`);
@@ -531,8 +531,7 @@ RemoteVideo.prototype.setDisplayName = function(displayName) {
531 531
         return;
532 532
     }
533 533
 
534
-    this.updateDisplayName({
535
-        displayName: displayName || interfaceConfig.DEFAULT_REMOTE_DISPLAY_NAME,
534
+    this._renderDisplayName({
536 535
         elementID: `${this.videoSpanId}_name`,
537 536
         participantID: this.id
538 537
     });

+ 3
- 1
modules/UI/videolayout/SmallVideo.js ファイルの表示

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

+ 3
- 3
modules/UI/videolayout/VideoLayout.js ファイルの表示

@@ -659,15 +659,15 @@ const VideoLayout = {
659 659
     /**
660 660
      * Display name changed.
661 661
      */
662
-    onDisplayNameChanged(id, displayName, status) {
662
+    onDisplayNameChanged(id) {
663 663
         if (id === 'localVideoContainer'
664 664
             || APP.conference.isLocalId(id)) {
665
-            localVideoThumbnail.setDisplayName(displayName);
665
+            localVideoThumbnail.updateDisplayName();
666 666
         } else {
667 667
             const remoteVideo = remoteVideos[id];
668 668
 
669 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,7 +8,8 @@ import { appendSuffix } from '../functions';
8 8
 
9 9
 import { translate } from '../../base/i18n';
10 10
 import {
11
-    getParticipantDisplayName
11
+    getParticipantDisplayName,
12
+    getParticipantById
12 13
 } from '../../base/participants';
13 14
 import { updateSettings } from '../../base/settings';
14 15
 
@@ -18,9 +19,15 @@ import { updateSettings } from '../../base/settings';
18 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 33
      * Whether or not the display name should be editable on click.
@@ -78,6 +85,10 @@ type State = {
78 85
 class DisplayName extends Component<Props, State> {
79 86
     _nameInput: ?HTMLInputElement;
80 87
 
88
+    static defaultProps = {
89
+        _configuredDisplayName: ''
90
+    };
91
+
81 92
     /**
82 93
      * Initializes a new {@code DisplayName} instance.
83 94
      *
@@ -134,7 +145,7 @@ class DisplayName extends Component<Props, State> {
134 145
      */
135 146
     render() {
136 147
         const {
137
-            _displayName,
148
+            _nameToDisplay,
138 149
             allowEditing,
139 150
             displayNameSuffix,
140 151
             elementID,
@@ -163,7 +174,7 @@ class DisplayName extends Component<Props, State> {
163 174
                 className = 'displayname'
164 175
                 id = { elementID }
165 176
                 onClick = { this._onStartEditing }>
166
-                { appendSuffix(_displayName, displayNameSuffix) }
177
+                { appendSuffix(_nameToDisplay, displayNameSuffix) }
167 178
             </span>
168 179
         );
169 180
     }
@@ -212,7 +223,7 @@ class DisplayName extends Component<Props, State> {
212 223
         if (this.props.allowEditing) {
213 224
             this.setState({
214 225
                 isEditing: true,
215
-                editDisplayNameValue: this.props._displayName || ''
226
+                editDisplayNameValue: this.props._configuredDisplayName
216 227
             });
217 228
         }
218 229
     }
@@ -268,14 +279,17 @@ class DisplayName extends Component<Props, State> {
268 279
  * @param {Props} ownProps - The own props of the component.
269 280
  * @private
270 281
  * @returns {{
271
- *     _displayName: string
282
+ *     _configuredDisplayName: string,
283
+ *     _nameToDisplay: string
272 284
  * }}
273 285
  */
274 286
 function _mapStateToProps(state, ownProps) {
275 287
     const { participantID } = ownProps;
288
+    const participant = getParticipantById(state, participantID);
276 289
 
277 290
     return {
278
-        _displayName: getParticipantDisplayName(
291
+        _configuredDisplayName: participant && participant.name,
292
+        _nameToDisplay: getParticipantDisplayName(
279 293
             state, participantID)
280 294
     };
281 295
 }

読み込み中…
キャンセル
保存