Attempt to get rid of unwanted trans-rooms socket listen/message...
[vchess.git] / client / src / views / Game.vue
index f12290d..89edb96 100644 (file)
@@ -236,7 +236,10 @@ export default {
         clearInterval(this.retrySendmove);
       if (!!this.clockUpdate)
         clearInterval(this.clockUpdate);
+      this.conn.removeEventListener("message", this.socketMessageListener);
+      this.conn.removeEventListener("close", this.socketCloseListener);
       this.send("disconnect");
+      this.conn = null;
     },
     visibilityChange: function() {
       // TODO: Use document.hidden? https://webplatform.news/issues/2019-03-27
@@ -458,9 +461,11 @@ export default {
         case "connect":
           if (!this.people[data.from]) {
             this.people[data.from] = { focus: true };
-            this.$forceUpdate(); //TODO: shouldn't be required
             this.newConnect[data.from] = true; //for self multi-connects tests
             this.send("askidentity", { target: data.from });
+          } else if (!this.people[data.from].focus) {
+            this.people[data.from].focus = true;
+            this.$forceUpdate(); //TODO: shouldn't be required
           }
           break;
         case "disconnect":