- let serverGames = res.games.filter(g => {
- const mySide =
- g.players[0].uid == this.st.user.id
- ? "White"
- : "Black";
- return !g["deletedBy" + mySide];
- });
- serverGames.forEach(g => g.type = "corr");
- this.decorate(serverGames);
- this.corrGames = serverGames;
- adjustAndSetDisplay();
+ // These games are garanteed to not be deleted
+ this.corrGames = res.games;
+ this.corrGames.forEach(g => g.type = "corr");
+ this.decorate(this.corrGames);
+ // Now ask completed games (partial list)
+ ajax(
+ "/completedgames",
+ "GET",
+ {
+ data: { cursor: this.cursor },
+ success: (res2) => {
+ if (res2.games.length > 0) {
+ const L = res2.games.length;
+ this.cursor = res2.games[L - 1].created;
+ let completedGames = res2.games;
+ completedGames.forEach(g => g.type = "corr");
+ this.decorate(completedGames);
+ this.corrGames = this.corrGames.concat(completedGames);
+ adjustAndSetDisplay();
+ }
+ }
+ }
+ );