X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fviews%2FGame.vue;h=0662fe840d78f059bd35ad5309ede2669a0de99c;hb=a2bd587aebc0104db71f9404aadeec72c9141102;hp=6339a3cedce33b2c60aaf899a9390ab82dc53d74;hpb=3f22c2c3939dfd6bd66da26e6d6d9848c6da86d2;p=vchess.git diff --git a/client/src/views/Game.vue b/client/src/views/Game.vue index 6339a3ce..0662fe84 100644 --- a/client/src/views/Game.vue +++ b/client/src/views/Game.vue @@ -192,7 +192,10 @@ export default { }, watch: { $route: function(to, from) { - if (from.params["id"] != to.params["id"]) { + if (to.path.length < 6 || to.path.substr(6) != "/game/") + // Page change + this.cleanBeforeDestroy(); + else if (from.params["id"] != to.params["id"]) { // Change everything: this.cleanBeforeDestroy(); let boardDiv = document.querySelector(".game"); @@ -210,7 +213,6 @@ export default { this.atCreation(); }, mounted: function() { - document.addEventListener('visibilitychange', this.visibilityChange); ["chatWrap", "infoDiv"].forEach(eltName => { document.getElementById(eltName) .addEventListener("click", processModalClick); @@ -223,10 +225,19 @@ export default { } }, beforeDestroy: function() { - document.removeEventListener('visibilitychange', this.visibilityChange); this.cleanBeforeDestroy(); }, methods: { + cleanBeforeDestroy: function() { + document.removeEventListener('visibilitychange', this.visibilityChange); + if (!!this.askLastate) + clearInterval(this.askLastate); + if (!!this.retrySendmove) + clearInterval(this.retrySendmove); + if (!!this.clockUpdate) + clearInterval(this.clockUpdate); + this.send("disconnect"); + }, visibilityChange: function() { // TODO: Use document.hidden? https://webplatform.news/issues/2019-03-27 this.send( @@ -236,6 +247,7 @@ export default { ); }, atCreation: function() { + document.addEventListener('visibilitychange', this.visibilityChange); // 0] (Re)Set variables this.gameRef = this.$route.params["id"]; // next = next corr games IDs to navigate faster (if applicable) @@ -310,15 +322,6 @@ export default { socketInit(() => { this.send("askfullgame"); }); }); }, - cleanBeforeDestroy: function() { - if (!!this.askLastate) - clearInterval(this.askLastate); - if (!!this.retrySendmove) - clearInterval(this.retrySendmove); - if (!!this.clockUpdate) - clearInterval(this.clockUpdate); - this.send("disconnect"); - }, roomInit: function() { if (!this.roomInitialized) { // Notify the room only now that I connected, because @@ -457,6 +460,9 @@ export default { this.people[data.from] = { focus: true }; 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": @@ -519,6 +525,7 @@ export default { if (!this.killed[this.st.user.sid]) { // Ask potentially missed last state, if opponent and I play if ( + !this.gotLastate && !!this.game.mycolor && this.game.type == "live" && this.game.score == "*" && @@ -1409,7 +1416,7 @@ button margin: 0 display: inline-flex img - height: 24px + height: 22px display: flex @media screen and (max-width: 767px) height: 18px