From 39c74a7e8d721338ef18bd9959ee825bad3d1043 Mon Sep 17 00:00:00 2001 From: James Ketrenos Date: Tue, 8 Mar 2022 16:37:43 -0800 Subject: [PATCH] Fix lack of keys in chat Signed-off-by: James Ketrenos --- client/src/Chat.js | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/client/src/Chat.js b/client/src/Chat.js index 14b61c5..de309a5 100644 --- a/client/src/Chat.js +++ b/client/src/Chat.js @@ -81,19 +81,25 @@ const Chat = ({ table }) => { } const messages = table.game && table.game.chat.map((item, index) => { + const punctuation = item.message.match(/(\.+$)/); + let period; + if (punctuation) { + period = punctuation[1]; + } else { + period = ''; + } let lines = item.message.split('.'); - const message = lines.map((line, index) => { - if (line.trim() === '') { - return <>; - } + const message = lines + .filter(line => line.trim() !== '') + .map((line, index) => { /* If the date is in the future, set it to now */ const dice = line.match(/^(.*rolled )([1-6])(, ([1-6]))?(.*)$/); if (dice) { if (dice[4]) { return
{dice[1]}, - {dice[5]}.
; + {dice[5]}{ period }; } else { - return
{dice[1]}{dice[5]}.
; + return
{dice[1]}{dice[5]}{ period }
; } } @@ -109,7 +115,7 @@ const Chat = ({ table }) => { start = ''; } } - return
{ message }.
; + return
{ message }{ period }
; }); return (