- // Ignore games where I play (will go in MyGames page)
- if (game.players.every(p =>
- p.sid != this.st.user.sid || p.uid != this.st.user.id))
- {
- let locGame = this.games.find(g => g.id == game.id);
- if (!locGame) {
- let newGame = game;
- newGame.type = this.classifyObject(game);
- newGame.vname = this.getVname(game.vid);
- if (!game.score)
- // New game from Hall
- newGame.score = "*";
- newGame.rids = [game.rid];
- delete newGame["rid"];
- this.games.push(newGame);
- if (
- (newGame.type == "live" && this.gdisplay == "corr") ||
- (newGame.type == "corr" && this.gdisplay == "live")
- ) {
- document
- .getElementById("btnG" + newGame.type)
- .classList.add("somethingnew");
- }
- } else {
- // Append rid (if not already in list)
- if (!locGame.rids.includes(game.rid)) locGame.rids.push(game.rid);
+ // Ignore games where I play (will go in MyGames page),
+ // and also games that I already received.
+ if (
+ this.games.findIndex(g => g.id == game.id) == -1 &&
+ game.players.every(p => {
+ return (
+ p.sid != this.st.user.sid &&
+ (p.id == 0 || p.id != this.st.user.id)
+ );
+ })
+ ) {
+ let newGame = game;
+ newGame.type = this.classifyObject(game);
+ this.setVname(game);
+ if (!game.score)
+ // New game from Hall
+ newGame.score = "*";
+ // TODO: remove patch on next line (options || "{}")
+ newGame.options = JSON.parse(newGame.options || "{}");
+ this.games.push(newGame);
+ if (
+ newGame.score == '*' &&
+ (newGame.type == "live" && this.gdisplay == "corr") ||
+ (newGame.type == "corr" && this.gdisplay == "live")
+ ) {
+ document
+ .getElementById("btnG" + newGame.type)
+ .classList.add("somethingnew");