From 1133fe2d2ba9cd86d92f3fb0537e02c36a9e7c0b Mon Sep 17 00:00:00 2001 From: Mitchell McCaffrey Date: Fri, 20 Mar 2020 12:11:28 +1100 Subject: [PATCH] Fixed a bug with an empty token being sent on a new connection --- src/routes/Game.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/routes/Game.js b/src/routes/Game.js index a5f0de3..edbf9d9 100644 --- a/src/routes/Game.js +++ b/src/routes/Game.js @@ -49,7 +49,8 @@ function Game() { [token.id]: token })); for (let connection of Object.values(connections)) { - connection.send({ id: "token", data: token }); + const data = { [token.id]: token }; + connection.send({ id: "token", data }); } } @@ -61,10 +62,9 @@ function Game() { setImageSource(URL.createObjectURL(imageDataRef.current)); } if (data.id === "token") { - const token = data.data; setMapTokens(prevMapTokens => ({ ...prevMapTokens, - [token.id]: token + ...data.data })); } });