From f25ae50c77565c24dcba716befc9a49a9be859a8 Mon Sep 17 00:00:00 2001 From: zikaeroh <48577114+zikaeroh@users.noreply.github.com> Date: Sat, 23 May 2020 16:52:07 -0700 Subject: [PATCH] Preprocess words clientside a bit more --- frontend/src/pages/gameView.tsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/frontend/src/pages/gameView.tsx b/frontend/src/pages/gameView.tsx index 2eb2d5e..585095c 100644 --- a/frontend/src/pages/gameView.tsx +++ b/frontend/src/pages/gameView.tsx @@ -360,8 +360,10 @@ const Sidebar = ({ send, state, pState, pTeam }: GameViewProps) => { for (let i = 0; i < files.length; i++) { const file = files[i]; const name = file.name.substring(0, file.name.lastIndexOf('.')) || file.name; - const text = (await file.text()).trim(); - const words = text.split('\n'); + const words = (await file.text()) + .split('\n') + .map((word) => word.trim()) + .filter((word) => word); if (words.length < 25) { continue; @@ -370,7 +372,9 @@ const Sidebar = ({ send, state, pState, pTeam }: GameViewProps) => { packs.push({ name, words }); } - send.addPacks(packs); + if (packs.length) { + send.addPacks(packs); + } }} />