X-Git-Url: https://git.auder.net/?p=vchess.git;a=blobdiff_plain;f=client%2Fsrc%2Fviews%2FMyGames.vue;h=3c2f460b41da35b7ab60f7f3a1a2a5d16e50a441;hp=60783941ff005005a2ec1dff3decb7cee385a173;hb=1112f1fdd39a4599cebc4b0b03bee1d28f1236ee;hpb=a8f0bbcb3808c8a8af548ab335c61674cffcb6c3 diff --git a/client/src/views/MyGames.vue b/client/src/views/MyGames.vue index 60783941..3c2f460b 100644 --- a/client/src/views/MyGames.vue +++ b/client/src/views/MyGames.vue @@ -58,7 +58,13 @@ export default { connexionString: "" }; }, + watch: { + $route: function(to, from) { + if (to.path != "/mygames") this.cleanBeforeDestroy(); + } + }, created: function() { + window.addEventListener("beforeunload", this.cleanBeforeDestroy); // Initialize connection this.connexionString = params.socketUrl + @@ -132,9 +138,13 @@ export default { }); }, beforeDestroy: function() { - this.conn.send(JSON.stringify({code: "disconnect"})); + this.cleanBeforeDestroy(); }, methods: { + cleanBeforeDestroy: function() { + window.removeEventListener("beforeunload", this.cleanBeforeDestroy); + this.conn.send(JSON.stringify({code: "disconnect"})); + }, setDisplay: function(type, e) { this.display = type; localStorage.setItem("type-myGames", type);