Browse Source

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

j8
damencho 9 years ago
parent
commit
0974e31da1
1 changed files with 22 additions and 6 deletions
  1. 22
    6
      modules/UI/videolayout/ConnectionIndicator.js

+ 22
- 6
modules/UI/videolayout/ConnectionIndicator.js View File

270
             APP.translation.translateString("connectionindicator.na") + "</div>",
270
             APP.translation.translateString("connectionindicator.na") + "</div>",
271
             skin: "black"});
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
     this.emptyIcon = this.connectionIndicatorContainer.appendChild(
284
     this.emptyIcon = this.connectionIndicatorContainer.appendChild(
274
         createIcon(["connection", "connection_empty"]));
285
         createIcon(["connection", "connection_empty"]));
275
     this.fullIcon = this.connectionIndicatorContainer.appendChild(
286
     this.fullIcon = this.connectionIndicatorContainer.appendChild(
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
 /**

Loading…
Cancel
Save