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,7 +516,11 @@ RemoteVideo.prototype.remove = function () {
516 516
     this.removeAudioLevelIndicator();
517 517
 
518 518
     this.removeConnectionIndicator();
519
+
519 520
     this.removeDisplayName();
521
+
522
+    this.removeAvatar();
523
+
520 524
     // Make sure that the large video is updated if are removing its
521 525
     // corresponding small video.
522 526
     this.VideoLayout.updateAfterThumbRemoved(this.id);
@@ -692,6 +696,10 @@ RemoteVideo.createContainer = function (spanId) {
692 696
     displayNameContainer.className = 'displayNameContainer';
693 697
     container.appendChild(displayNameContainer);
694 698
 
699
+    const avatarContainer = document.createElement('div');
700
+    avatarContainer.className = 'avatar-container';
701
+    container.appendChild(avatarContainer);
702
+
695 703
     var remotes = document.getElementById('filmstripRemoteVideosContainer');
696 704
     return remotes.appendChild(container);
697 705
 };

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

@@ -9,6 +9,9 @@ import { Provider } from 'react-redux';
9 9
 import { i18next } from '../../../react/features/base/i18n';
10 10
 import { AudioLevelIndicator }
11 11
     from '../../../react/features/audio-level-indicator';
12
+import {
13
+    Avatar as AvatarDisplay
14
+} from '../../../react/features/base/participants';
12 15
 import {
13 16
     ConnectionIndicator
14 17
 } from '../../../react/features/connection-indicator';
@@ -477,7 +480,7 @@ SmallVideo.prototype.selectVideoElement = function () {
477 480
  * element which displays the user's avatar.
478 481
  */
479 482
 SmallVideo.prototype.$avatar = function () {
480
-    return $('#' + this.videoSpanId + ' .userAvatar');
483
+    return $('#' + this.videoSpanId + ' .avatar-container');
481 484
 };
482 485
 
483 486
 /**
@@ -652,21 +655,40 @@ SmallVideo.prototype.updateView = function () {
652 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 665
 SmallVideo.prototype.avatarChanged = function (avatarUrl) {
656
-    var thumbnail = $('#' + this.videoSpanId);
657
-    var avatarSel = this.$avatar();
666
+    const thumbnail = this.$avatar().get(0);
658 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,6 +41,7 @@ export default class Filmstrip extends Component {
41 41
                             </div>
42 42
                             <div className = 'videocontainer__hoverOverlay' />
43 43
                             <div className = 'displayNameContainer' />
44
+                            <div className = 'avatar-container' />
44 45
                         </span>
45 46
                     </div>
46 47
                     <div

Loading…
Cancel
Save