Просмотр исходного кода

ref(LargeVideoManager): getCurrentContainer

Remove duplication and direct access to kind of private 'state' field by
introducing 'getCurrentContainer' method.
master
paweldomas 8 лет назад
Родитель
Сommit
badbedf0f5
2 измененных файлов: 20 добавлений и 6 удалений
  1. 19
    5
      modules/UI/videolayout/LargeVideoManager.js
  2. 1
    1
      modules/UI/videolayout/VideoLayout.js

+ 19
- 5
modules/UI/videolayout/LargeVideoManager.js Просмотреть файл

116
         if (!this.state) {
116
         if (!this.state) {
117
             return;
117
             return;
118
         }
118
         }
119
-        let container = this.getContainer(this.state);
119
+        const container = this.getCurrentContainer();
120
+
120
         container.onHoverIn(e);
121
         container.onHoverIn(e);
121
     }
122
     }
122
 
123
 
124
         if (!this.state) {
125
         if (!this.state) {
125
             return;
126
             return;
126
         }
127
         }
127
-        let container = this.getContainer(this.state);
128
+        const container = this.getCurrentContainer();
129
+
128
         container.onHoverOut(e);
130
         container.onHoverOut(e);
129
     }
131
     }
130
 
132
 
148
     }
150
     }
149
 
151
 
150
     get id () {
152
     get id () {
151
-        let container = this.getContainer(this.state);
153
+        const container = this.getCurrentContainer();
152
         return container.id;
154
         return container.id;
153
     }
155
     }
154
 
156
 
161
 
163
 
162
         // Include hide()/fadeOut only if we're switching between users
164
         // Include hide()/fadeOut only if we're switching between users
163
         const isUserSwitch = this.newStreamData.id != this.id;
165
         const isUserSwitch = this.newStreamData.id != this.id;
164
-        const container = this.getContainer(this.state);
166
+        const container = this.getCurrentContainer();
165
         const preUpdate = isUserSwitch ? container.hide() : Promise.resolve();
167
         const preUpdate = isUserSwitch ? container.hide() : Promise.resolve();
166
 
168
 
167
         preUpdate.then(() => {
169
         preUpdate.then(() => {
177
 
179
 
178
             logger.info("hover in %s", id);
180
             logger.info("hover in %s", id);
179
             this.state = videoType;
181
             this.state = videoType;
180
-            const container = this.getContainer(this.state);
182
+            const container = this.getCurrentContainer();
181
             container.setStream(id, stream, videoType);
183
             container.setStream(id, stream, videoType);
182
 
184
 
183
             // change the avatar url on large
185
             // change the avatar url on large
509
         return container;
511
         return container;
510
     }
512
     }
511
 
513
 
514
+    /**
515
+     * Returns {@link LargeContainer} for the current {@link state}
516
+     *
517
+     * @return {LargeContainer}
518
+     *
519
+     * @throws an <tt>Error</tt> if there is no container for the current
520
+     * {@link state}.
521
+     */
522
+    getCurrentContainer() {
523
+        return this.getContainer(this.state);
524
+    }
525
+
512
     /**
526
     /**
513
      * Remove Large container of specified type.
527
      * Remove Large container of specified type.
514
      * @param {string} type container type.
528
      * @param {string} type container type.

+ 1
- 1
modules/UI/videolayout/VideoLayout.js Просмотреть файл

981
      * video.
981
      * video.
982
      */
982
      */
983
     getCurrentlyOnLargeContainer () {
983
     getCurrentlyOnLargeContainer () {
984
-        return largeVideo.getContainer(largeVideo.state);
984
+        return largeVideo.getCurrentContainer();
985
     },
985
     },
986
 
986
 
987
     isCurrentlyOnLarge (id) {
987
     isCurrentlyOnLarge (id) {

Загрузка…
Отмена
Сохранить