From 5385f7be048a057e00161a381268d87753b3d1d7 Mon Sep 17 00:00:00 2001 From: sepia Date: Wed, 23 Jul 2025 15:13:22 -0500 Subject: [PATCH] Silence errors when handle-redirects sees a message that was meant for someone else --- public/scripts/handle-redirects.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/public/scripts/handle-redirects.js b/public/scripts/handle-redirects.js index bc8dbff..9d7ea65 100644 --- a/public/scripts/handle-redirects.js +++ b/public/scripts/handle-redirects.js @@ -1,7 +1,10 @@ document.addEventListener('htmx:wsAfterMessage', function (e) { - console.log(e.detail.message); - const message = JSON.parse(e.detail.message); - if (message.type === 'redirect_to_game') { - window.location.href = '/?gameId=' + message.gameId; + try { + const message = JSON.parse(e.detail.message); + if (message.type === 'redirect_to_game') { + window.location.href = '/?gameId=' + message.gameId; + } + } catch (error) { + // some messages are plain divs and some are json. This usually means it was a div one } });