Browse Source

feat(avatar): SmallVideo uses the existing Avatar component. (#1712)

* feat(avatar): SmallVideo uses the existing Avatar component.
j8
virtuacoplenny 7 years ago
parent
commit
0de032ebd7

+ 8
- 0
modules/UI/videolayout/RemoteVideo.js View File

516
     this.removeAudioLevelIndicator();
516
     this.removeAudioLevelIndicator();
517
 
517
 
518
     this.removeConnectionIndicator();
518
     this.removeConnectionIndicator();
519
+
519
     this.removeDisplayName();
520
     this.removeDisplayName();
521
+
522
+    this.removeAvatar();
523
+
520
     // Make sure that the large video is updated if are removing its
524
     // Make sure that the large video is updated if are removing its
521
     // corresponding small video.
525
     // corresponding small video.
522
     this.VideoLayout.updateAfterThumbRemoved(this.id);
526
     this.VideoLayout.updateAfterThumbRemoved(this.id);
692
     displayNameContainer.className = 'displayNameContainer';
696
     displayNameContainer.className = 'displayNameContainer';
693
     container.appendChild(displayNameContainer);
697
     container.appendChild(displayNameContainer);
694
 
698
 
699
+    const avatarContainer = document.createElement('div');
700
+    avatarContainer.className = 'avatar-container';
701
+    container.appendChild(avatarContainer);
702
+
695
     var remotes = document.getElementById('filmstripRemoteVideosContainer');
703
     var remotes = document.getElementById('filmstripRemoteVideosContainer');
696
     return remotes.appendChild(container);
704
     return remotes.appendChild(container);
697
 };
705
 };

+ 35
- 13
modules/UI/videolayout/SmallVideo.js View File

9
 import { i18next } from '../../../react/features/base/i18n';
9
 import { i18next } from '../../../react/features/base/i18n';
10
 import { AudioLevelIndicator }
10
 import { AudioLevelIndicator }
11
     from '../../../react/features/audio-level-indicator';
11
     from '../../../react/features/audio-level-indicator';
12
+import {
13
+    Avatar as AvatarDisplay
14
+} from '../../../react/features/base/participants';
12
 import {
15
 import {
13
     ConnectionIndicator
16
     ConnectionIndicator
14
 } from '../../../react/features/connection-indicator';
17
 } from '../../../react/features/connection-indicator';
477
  * element which displays the user's avatar.
480
  * element which displays the user's avatar.
478
  */
481
  */
479
 SmallVideo.prototype.$avatar = function () {
482
 SmallVideo.prototype.$avatar = function () {
480
-    return $('#' + this.videoSpanId + ' .userAvatar');
483
+    return $('#' + this.videoSpanId + ' .avatar-container');
481
 };
484
 };
482
 
485
 
483
 /**
486
 /**
652
                                 || displayMode === DISPLAY_VIDEO_WITH_NAME));
655
                                 || displayMode === DISPLAY_VIDEO_WITH_NAME));
653
 };
656
 };
654
 
657
 
658
+/**
659
+ * Updates the react component displaying the avatar with the passed in avatar
660
+ * url.
661
+ *
662
+ * @param {string} avatarUrl - The uri to the avatar image.
663
+ * @returns {void}
664
+ */
655
 SmallVideo.prototype.avatarChanged = function (avatarUrl) {
665
 SmallVideo.prototype.avatarChanged = function (avatarUrl) {
656
-    var thumbnail = $('#' + this.videoSpanId);
657
-    var avatarSel = this.$avatar();
666
+    const thumbnail = this.$avatar().get(0);
658
     this.hasAvatar = true;
667
     this.hasAvatar = true;
659
 
668
 
660
-    // set the avatar in the thumbnail
661
-    if (avatarSel && avatarSel.length > 0) {
662
-        avatarSel[0].src = avatarUrl;
663
-    } else {
664
-        if (thumbnail && thumbnail.length > 0) {
665
-            var avatarElement = document.createElement('img');
666
-            avatarElement.className = 'userAvatar';
667
-            avatarElement.src = avatarUrl;
668
-            thumbnail.append(avatarElement);
669
-        }
669
+    if (thumbnail) {
670
+        /* jshint ignore:start */
671
+        ReactDOM.render(
672
+            <AvatarDisplay
673
+                className = 'userAvatar'
674
+                uri = { avatarUrl } />,
675
+            thumbnail
676
+        );
677
+        /* jshint ignore:end */
678
+    }
679
+};
680
+
681
+/**
682
+ * Unmounts any attached react components (particular the avatar image) from
683
+ * the avatar container.
684
+ *
685
+ * @returns {void}
686
+ */
687
+SmallVideo.prototype.removeAvatar = function () {
688
+    const thumbnail = this.$avatar().get(0);
689
+
690
+    if (thumbnail) {
691
+        ReactDOM.unmountComponentAtNode(thumbnail);
670
     }
692
     }
671
 };
693
 };
672
 
694
 

+ 1
- 0
react/features/filmstrip/components/Filmstrip.web.js View File

41
                             </div>
41
                             </div>
42
                             <div className = 'videocontainer__hoverOverlay' />
42
                             <div className = 'videocontainer__hoverOverlay' />
43
                             <div className = 'displayNameContainer' />
43
                             <div className = 'displayNameContainer' />
44
+                            <div className = 'avatar-container' />
44
                         </span>
45
                         </span>
45
                     </div>
46
                     </div>
46
                     <div
47
                     <div

Loading…
Cancel
Save