From 8844bfedfc84e6f6181f3999f01e864efdc656ea Mon Sep 17 00:00:00 2001 From: Aevann Date: Wed, 13 Nov 2024 19:48:37 +0200 Subject: [PATCH] make chat work on back button --- files/assets/js/chat.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/files/assets/js/chat.js b/files/assets/js/chat.js index 2c805cc42..1ddbbda99 100644 --- a/files/assets/js/chat.js +++ b/files/assets/js/chat.js @@ -1,3 +1,10 @@ +let socket = io() +addEventListener("pageshow", () => { + socket.disconnect(); + socket.connect(); +}); + + function formatHourMinute(d) { return d.toLocaleTimeString([], {timeStyle: 'short'}) } @@ -7,8 +14,6 @@ for (const e of document.querySelectorAll('[data-time]')) { const ua = window.navigator.userAgent -const socket = io() - const chat = document.getElementById('chat') const chat_id = document.getElementById('chat_id').value const chatline = document.getElementsByClassName('chat-line')[0]