X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fviews%2FHall.vue;h=0e2c1c60b843cce879ee8a57c44d55af5b1aa0a9;hb=57078452549f252460d45e91b84c7eea40dd3e9c;hp=133a5f9e9ced98cc58dd59bd69292faa88260556;hpb=cd49e617866590dbc68530ad961b109cdbe1ce55;p=vchess.git diff --git a/client/src/views/Hall.vue b/client/src/views/Hall.vue index 133a5f9e..0e2c1c60 100644 --- a/client/src/views/Hall.vue +++ b/client/src/views/Hall.vue @@ -572,14 +572,12 @@ export default { } }); const gid = gids[Math.floor(Math.random() * gids.length)]; - const game = this.games.find(g => g.id == gid); - if (!!game) this.showGame(game); - else this.$router.push("/game/" + gid); //game vs. me + window.open("/#/game/" + gid, "_blank"); }, showGame: function(g) { // NOTE: we are an observer, since only games I don't play are shown here // ==> Moves sent by connected remote player(s) if live game - this.$router.push("/game/" + g.id); + window.open("/#/game/" + g.id, "_blank"); }, toggleSocialColor: function(action) { if (!action && document.getElementById("modalPeople").checked) @@ -822,12 +820,13 @@ export default { // 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) ); - }) && this.games.findIndex(g => g.id == game.id) == -1 + }) ) { let newGame = game; newGame.type = this.classifyObject(game); @@ -837,6 +836,7 @@ export default { newGame.score = "*"; this.games.push(newGame); if ( + newGame.score == '*' && (newGame.type == "live" && this.gdisplay == "corr") || (newGame.type == "corr" && this.gdisplay == "live") ) { @@ -888,7 +888,8 @@ export default { if ( this.cursor == Number.MAX_SAFE_INTEGER && this.games.length == 0 && - this.gdisplay == "live" + this.gdisplay == "live" && + res.games.some(g => g.score == '*') ) { // First loading: show indicators document @@ -1287,13 +1288,13 @@ export default { () => { const myIdx = (game.players[0].sid == this.st.user.sid ? 0 : 1); GameStorage.add(game, (err) => { - // If an error occurred, game is not added: a tab already - // added the game. Maybe a focused one, maybe not. - // We know for sure that it emitted the gong start sound. - // ==> Do not play it again. - if (!err && this.st.settings.sound) - new Audio("/sounds/newgame.flac").play().catch(() => {}); + // If an error occurred, game is not added: the focused tab + // already added the game. if (!this.focus) { + if (this.st.settings.sound) + // This will be played several times if several hidden tabs + // on Hall... TODO: fix that (how ?!) + new Audio("/sounds/newgame.flac").play().catch(() => {}); notify( "New live game", { body: "vs " + game.players[1-myIdx].name || "@nonymous" } @@ -1302,7 +1303,7 @@ export default { this.$router.push("/game/" + gameInfo.id); }); }, - this.focus ? 500 + 1000 * Math.random() : 0 + this.focus ? 0 : 500 + 1000 * Math.random() ); } } @@ -1311,7 +1312,7 @@ export default {