From 5fd5fb22de02ed6c585e86a1c3dda50ff6071d2f Mon Sep 17 00:00:00 2001
From: Benjamin Auder <benjamin.auder@somewhere>
Date: Wed, 5 Feb 2020 18:51:36 +0100
Subject: [PATCH] Small fixes

---
 client/src/components/GameList.vue |  1 +
 client/src/views/Game.vue          | 28 ++++++++++++++++------------
 2 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/client/src/components/GameList.vue b/client/src/components/GameList.vue
index c1557a23..d0ea2f01 100644
--- a/client/src/components/GameList.vue
+++ b/client/src/components/GameList.vue
@@ -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++;
           }
diff --git a/client/src/views/Game.vue b/client/src/views/Game.vue
index a7096e52..d366bb2d 100644
--- a/client/src/views/Game.vue
+++ b/client/src/views/Game.vue
@@ -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
-- 
2.44.0