From badbedf0f545517d02b7aa3936949f8bec34ffca Mon Sep 17 00:00:00 2001 From: paweldomas Date: Mon, 10 Jul 2017 11:02:22 +0200 Subject: [PATCH] ref(LargeVideoManager): getCurrentContainer Remove duplication and direct access to kind of private 'state' field by introducing 'getCurrentContainer' method. --- modules/UI/videolayout/LargeVideoManager.js | 24 ++++++++++++++++----- modules/UI/videolayout/VideoLayout.js | 2 +- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/modules/UI/videolayout/LargeVideoManager.js b/modules/UI/videolayout/LargeVideoManager.js index 2ca754093..e47de9e57 100644 --- a/modules/UI/videolayout/LargeVideoManager.js +++ b/modules/UI/videolayout/LargeVideoManager.js @@ -116,7 +116,8 @@ export default class LargeVideoManager { if (!this.state) { return; } - let container = this.getContainer(this.state); + const container = this.getCurrentContainer(); + container.onHoverIn(e); } @@ -124,7 +125,8 @@ export default class LargeVideoManager { if (!this.state) { return; } - let container = this.getContainer(this.state); + const container = this.getCurrentContainer(); + container.onHoverOut(e); } @@ -148,7 +150,7 @@ export default class LargeVideoManager { } get id () { - let container = this.getContainer(this.state); + const container = this.getCurrentContainer(); return container.id; } @@ -161,7 +163,7 @@ export default class LargeVideoManager { // Include hide()/fadeOut only if we're switching between users const isUserSwitch = this.newStreamData.id != this.id; - const container = this.getContainer(this.state); + const container = this.getCurrentContainer(); const preUpdate = isUserSwitch ? container.hide() : Promise.resolve(); preUpdate.then(() => { @@ -177,7 +179,7 @@ export default class LargeVideoManager { logger.info("hover in %s", id); this.state = videoType; - const container = this.getContainer(this.state); + const container = this.getCurrentContainer(); container.setStream(id, stream, videoType); // change the avatar url on large @@ -509,6 +511,18 @@ export default class LargeVideoManager { return container; } + /** + * Returns {@link LargeContainer} for the current {@link state} + * + * @return {LargeContainer} + * + * @throws an Error if there is no container for the current + * {@link state}. + */ + getCurrentContainer() { + return this.getContainer(this.state); + } + /** * Remove Large container of specified type. * @param {string} type container type. diff --git a/modules/UI/videolayout/VideoLayout.js b/modules/UI/videolayout/VideoLayout.js index e45f8dd86..5a1f7afbe 100644 --- a/modules/UI/videolayout/VideoLayout.js +++ b/modules/UI/videolayout/VideoLayout.js @@ -981,7 +981,7 @@ var VideoLayout = { * video. */ getCurrentlyOnLargeContainer () { - return largeVideo.getContainer(largeVideo.state); + return largeVideo.getCurrentContainer(); }, isCurrentlyOnLarge (id) {