repo: janusweb
action: commit
revision: 
path_from: 
revision_from: b78484e1322e621ca9711d91ad5545eca2f06c16:
path_to: 
revision_to: 
git.thebackupbox.net
janusweb
git clone git://git.thebackupbox.net/janusweb
commit b78484e1322e621ca9711d91ad5545eca2f06c16
Author: James Baicoianu 
Date:   Mon Feb 17 07:17:28 2020 -0800

    Fixed canvas creation race condition

diff --git a/media/assets/webui/apps/navigation/navigation.js b/media/assets/webui/apps/navigation/navigation.js
index 029deb9a93beada74afb2d209cf544d3a22f23fa..
index ..99f66a370ac3dc755418b06e3a33631911add4e2 100644
--- a/media/assets/webui/apps/navigation/navigation.js
+++ b/media/assets/webui/apps/navigation/navigation.js
@@ -45,8 +45,6 @@ elation.elements.define('janus.ui.statusindicator', class extends elation.elemen
     });
     setTimeout(() => { this.tooltip.hide(); }, 1000);

-    this.canvas = document.createElement('canvas');
-    this.inner.appendChild(this.canvas);

     elation.events.add(this.janusweb, 'room_load_start', (ev) => this.updateCurrentURL());

@@ -61,7 +59,7 @@ elation.elements.define('janus.ui.statusindicator', class extends elation.elemen
     elation.events.add([this, this.tooltip], 'mouseout', (ev) => this.handleMouseOut(ev));
   }
   render() {
-    var canvas = this.canvas;
+    var canvas = this.getCanvas();
     var ctx = canvas.getContext('2d');
     canvas.width = this.inner.offsetWidth;
     canvas.height = this.inner.offsetHeight;
@@ -73,6 +71,14 @@ elation.elements.define('janus.ui.statusindicator', class extends elation.elemen
     ctx.fillStyle = (this.currentstatus == 'complete' ? 'green' : 'darkgreen');
     ctx.fill();
   }
+  getCanvas() {
+    if (!this.canvas) {
+      this.canvas = document.createElement('canvas');
+      this.inner.appendChild(this.canvas);
+    }
+    return this.canvas;
+  }
+
   getClient() {
     var node = this;
     while (node) {

-----END OF PAGE-----