Small fixes
authorBenjamin Auder <benjamin.auder@somewhere>
Wed, 5 Feb 2020 17:51:36 +0000 (18:51 +0100)
committerBenjamin Auder <benjamin.auder@somewhere>
Wed, 5 Feb 2020 17:51:36 +0000 (18:51 +0100)
client/src/components/GameList.vue
client/src/views/Game.vue

index c1557a2..d0ea2f0 100644 (file)
@@ -46,6 +46,7 @@ export default {
                 || g.players[0].sid == this.st.user.sid
               ? "w"
               : "b";
+            // I play in this game, so g.fen will be defined
             if (!!g.fen.match(" " + myColor + " "))
               priority++;
           }
index a7096e5..d366bb2 100644 (file)
@@ -223,19 +223,23 @@ export default {
           break;
         }
         case "askgame":
-          // Send current (live) game if not asked by opponent (!)
-          if (this.game.players.some(p => p.sid == data.from))
-            return;
-          const myGame =
+          // Send current (live) game if I play in (not an observer),
+          // and not asked by opponent (!)
+          if (this.game.type == "live"
+            && this.game.players.some(p => p.sid == this.st.user.sid)
+            && this.game.players.every(p => p.sid != data.from))
           {
-            // Minimal game informations:
-            id: this.game.id,
-            players: this.game.players,
-            vid: this.game.vid,
-            timeControl: this.game.timeControl,
-          };
-          this.st.conn.send(JSON.stringify({code:"game",
-            game:myGame, target:data.from}));
+            const myGame =
+            {
+              // Minimal game informations:
+              id: this.game.id,
+              players: this.game.players,
+              vid: this.game.vid,
+              timeControl: this.game.timeControl,
+            };
+            this.st.conn.send(JSON.stringify({code:"game",
+              game:myGame, target:data.from}));
+          }
           break;
         case "newmove":
           if (!!data.move.cancelDrawOffer) //opponent refuses draw