From c97830ea3ee97c6c408c62dab6c59da46cfd03d5 Mon Sep 17 00:00:00 2001
From: Benjamin Auder <benjamin.auder@somewhere>
Date: Tue, 21 Jan 2020 11:01:14 +0100
Subject: [PATCH] Fix chat issues when launching a game

---
 client/src/views/Hall.vue | 2 +-
 server/sockets.js         | 4 +++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/client/src/views/Hall.vue b/client/src/views/Hall.vue
index 60f62917..e0910c0c 100644
--- a/client/src/views/Hall.vue
+++ b/client/src/views/Hall.vue
@@ -8,7 +8,7 @@ main
         p(v-html="infoMessage")
   input#modalNewgame.modal(type="checkbox")
   div(role="dialog" aria-labelledby="titleFenedit")
-    .card.smallpad
+    .card.smallpad(@keyup.enter="newChallenge")
       label#closeNewgame.modal-close(for="modalNewgame")
       fieldset
         label(for="selectVariant") {{ st.tr["Variant"] }}
diff --git a/server/sockets.js b/server/sockets.js
index 891c516d..3b166530 100644
--- a/server/sockets.js
+++ b/server/sockets.js
@@ -110,7 +110,9 @@ module.exports = function(wss) {
           }
           break;
         case "newchat":
-          notifyRoom(query["page"], "newchat", {msg:obj.msg, name:obj.name});
+          // WARNING: do not use query["page"], because the page may change
+          notifyRoom(clients[sid].page, "newchat",
+            {msg: obj.msg, name: obj.name});
           break;
         // TODO: WebRTC instead in this case (most demanding?)
         case "newmove":
-- 
2.44.0