projects
/
vchess.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fixing attempt: clients now track tmpIds to know who is online/onfocus. Bug fixed...
[vchess.git]
/
client
/
src
/
views
/
MyGames.vue
diff --git
a/client/src/views/MyGames.vue
b/client/src/views/MyGames.vue
index
3c2f460
..
1e1c9e7
100644
(file)
--- a/
client/src/views/MyGames.vue
+++ b/
client/src/views/MyGames.vue
@@
-53,7
+53,7
@@
export default {
corr: Number.MAX_SAFE_INTEGER
},
// hasMore == TRUE: a priori there could be more games to load
corr: Number.MAX_SAFE_INTEGER
},
// hasMore == TRUE: a priori there could be more games to load
- hasMore: { live: true, corr:
true
},
+ hasMore: { live: true, corr:
store.state.user.id > 0
},
conn: null,
connexionString: ""
};
conn: null,
connexionString: ""
};
@@
-129,12
+129,7
@@
export default {
}
}
);
}
}
);
- } else {
- this.loadMore(
- "live",
- () => this.loadMore("corr", adjustAndSetDisplay)
- );
- }
+ } else this.loadMore("live", adjustAndSetDisplay);
});
},
beforeDestroy: function() {
});
},
beforeDestroy: function() {
@@
-143,7
+138,10
@@
export default {
methods: {
cleanBeforeDestroy: function() {
window.removeEventListener("beforeunload", this.cleanBeforeDestroy);
methods: {
cleanBeforeDestroy: function() {
window.removeEventListener("beforeunload", this.cleanBeforeDestroy);
+ this.conn.removeEventListener("message", this.socketMessageListener);
+ this.conn.removeEventListener("close", this.socketCloseListener);
this.conn.send(JSON.stringify({code: "disconnect"}));
this.conn.send(JSON.stringify({code: "disconnect"}));
+ this.conn = null;
},
setDisplay: function(type, e) {
this.display = type;
},
setDisplay: function(type, e) {
this.display = type;
@@
-182,6
+180,7
@@
export default {
});
},
socketMessageListener: function(msg) {
});
},
socketMessageListener: function(msg) {
+ if (!this.conn) return;
const data = JSON.parse(msg.data);
let gamesArrays = {
"corr": this.corrGames,
const data = JSON.parse(msg.data);
let gamesArrays = {
"corr": this.corrGames,
@@
-262,16
+261,18
@@
export default {
game.players[0].sid == this.st.user.sid
? game.players[1].sid
: game.players[0].sid;
game.players[0].sid == this.st.user.sid
? game.players[1].sid
: game.players[0].sid;
- this.conn.send(
- JSON.stringify(
- {
- code: "mabort",
- gid: game.id,
- // NOTE: target might not be online
- target: oppsid
- }
- )
- );
+ if (!!this.conn) {
+ this.conn.send(
+ JSON.stringify(
+ {
+ code: "mabort",
+ gid: game.id,
+ // NOTE: target might not be online
+ target: oppsid
+ }
+ )
+ );
+ }
}
else if (!game.deletedByWhite || !game.deletedByBlack) {
// Set score if game isn't deleted on server:
}
else if (!game.deletedByWhite || !game.deletedByBlack) {
// Set score if game isn't deleted on server:
@@
-291,7
+292,7
@@
export default {
}
},
loadMore: function(type, cb) {
}
},
loadMore: function(type, cb) {
- if (type == "corr") {
+ if (type == "corr"
&& this.st.user.id > 0
) {
ajax(
"/completedgames",
"GET",
ajax(
"/completedgames",
"GET",