Pārlūkot izejas kodu

Updates connection quality popover only if its visible or about to be visible.

j8
damencho 9 gadus atpakaļ
vecāks
revīzija
0974e31da1
1 mainītis faili ar 22 papildinājumiem un 6 dzēšanām
  1. 22
    6
      modules/UI/videolayout/ConnectionIndicator.js

+ 22
- 6
modules/UI/videolayout/ConnectionIndicator.js Parādīt failu

@@ -270,6 +270,17 @@ ConnectionIndicator.prototype.create = function () {
270 270
             APP.translation.translateString("connectionindicator.na") + "</div>",
271 271
             skin: "black"});
272 272
 
273
+    // override popover show method to make sure we will update the content
274
+    // before showing the popover
275
+    var origShowFunc = this.popover.show;
276
+    this.popover.show = function () {
277
+        // update content by forcing it, to finish even if popover
278
+        // is not visible
279
+        this.updatePopoverData(true);
280
+        // call the original show, passing its actual this
281
+        origShowFunc.call(this.popover);
282
+    }.bind(this);
283
+
273 284
     this.emptyIcon = this.connectionIndicatorContainer.appendChild(
274 285
         createIcon(["connection", "connection_empty"]));
275 286
     this.fullIcon = this.connectionIndicatorContainer.appendChild(
@@ -335,13 +346,18 @@ ConnectionIndicator.prototype.updateResolution = function (resolution) {
335 346
 };
336 347
 
337 348
 /**
338
- * Updates the content of the popover
349
+ * Updates the content of the popover if its visible
350
+ * @param force to work even if popover is not visible
339 351
  */
340
-ConnectionIndicator.prototype.updatePopoverData = function () {
341
-    this.popover.updateContent(
342
-        `<div class="connection_info">${this.generateText()}</div>`
343
-    );
344
-    APP.translation.translateElement($(".connection_info"));
352
+ConnectionIndicator.prototype.updatePopoverData = function (force) {
353
+    // generate content, translate it and add it to document only if
354
+    // popover is visible or we force to do so.
355
+    if(this.popover.popoverShown || force) {
356
+        this.popover.updateContent(
357
+            `<div class="connection_info">${this.generateText()}</div>`
358
+        );
359
+        APP.translation.translateElement($(".connection_info"));
360
+    }
345 361
 };
346 362
 
347 363
 /**

Notiek ielāde…
Atcelt
Saglabāt