From c815b1f25b7fdc63e8ec3f906c2a645760d297ac Mon Sep 17 00:00:00 2001 From: Boris Grozev Date: Mon, 31 Oct 2016 15:53:08 -0500 Subject: [PATCH] feat: Updates the GSM bars' thresholds. Adapts to changes in lib-jitsi-meet. Uses an Array which guarantees the order of its elements, and avoids setting a css property multiple times. --- modules/UI/videolayout/ConnectionIndicator.js | 45 +++++++++---------- 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/modules/UI/videolayout/ConnectionIndicator.js b/modules/UI/videolayout/ConnectionIndicator.js index 829c7c97d..18bff07ee 100644 --- a/modules/UI/videolayout/ConnectionIndicator.js +++ b/modules/UI/videolayout/ConnectionIndicator.js @@ -4,6 +4,23 @@ import JitsiPopover from "../util/JitsiPopover"; import VideoLayout from "./VideoLayout"; import UIUtil from "../util/UIUtil"; +/** + * Maps a connection quality value (in percent) to the width of the "full" icon. + */ +const qualityToWidth = [ + // Full (5 bars) + {percent: 80, width: "100%"}, + // 4 bars + {percent: 60, width: "80%"}, + // 3 bars + {percent: 40, width: "55%"}, + // 2 bars + {percent: 20, width: "40%"}, + // 1 bar + {percent: 0, width: "20%"} + // Note: we never show 0 bars. +]; + /** * Constructs new connection indicator. * @param videoContainer the video container associated with the indicator. @@ -24,24 +41,6 @@ function ConnectionIndicator(videoContainer, videoId) { this.create(); } -/** - * Values for the connection quality - * @type {{98: string, - * 81: string, - * 64: string, - * 47: string, - * 30: string, - * 0: string}} - */ -ConnectionIndicator.connectionQualityValues = { - 98: "100%", //full - 81: "80%",//4 bars - 64: "55%",//3 bars - 47: "40%",//2 bars - 30: "20%",//1 bar - 0: "0"//empty -}; - ConnectionIndicator.getIP = function(value) { return value.substring(0, value.lastIndexOf(":")); }; @@ -360,12 +359,10 @@ ConnectionIndicator.prototype.updateConnectionQuality = this.resolution = object.resolution; } } - for (var quality in ConnectionIndicator.connectionQualityValues) { - if (percent >= quality) { - this.fullIcon.style.width = - ConnectionIndicator.connectionQualityValues[quality]; - } - } + + let width = qualityToWidth.find(x => percent >= x.percent); + this.fullIcon.style.width = width.width; + if (object && typeof object.isResolutionHD === 'boolean') { this.isResolutionHD = object.isResolutionHD; }