From fc6148149eba4bb577bc5d7b3dc7a0417814b086 Mon Sep 17 00:00:00 2001 From: Natsumi Date: Fri, 6 Sep 2024 08:41:47 +1200 Subject: [PATCH] Fix websocket reconnecting --- html/src/app.js | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/html/src/app.js b/html/src/app.js index 787e6053..e84b415e 100644 --- a/html/src/app.js +++ b/html/src/app.js @@ -4246,9 +4246,11 @@ speechSynthesis.getVoices(); } if ( - args.params.type === 'friend' && - $app.localFavoriteFriendsGroups.includes("friend:" + args.params.tags) - ) { + args.params.type === 'friend' && + $app.localFavoriteFriendsGroups.includes( + 'friend:' + args.params.tags + ) + ) { $app.updateLocalFavoriteFriends(); } }); @@ -5317,6 +5319,15 @@ speechSynthesis.getVoices(); if ($app.debugWebSocket) { console.log('WebSocket closed'); } + workerTimers.setTimeout(() => { + if ( + this.isLoggedIn && + $app.friendLogInitStatus && + this.webSocket === null + ) { + this.getAuth(); + } + }, 5000); }; socket.onerror = () => { if (this.errorNoty) { @@ -5375,7 +5386,7 @@ speechSynthesis.getVoices(); }; API.reconnectWebSocket = function () { - if (!$app.friendLogInitStatus) { + if (!this.isLoggedIn || !$app.friendLogInitStatus) { return; } this.closeWebSocket(); @@ -8320,6 +8331,7 @@ speechSynthesis.getVoices(); }).show(); } this.isLoggedIn = false; + $app.friendLogInitStatus = false; }); API.$on('LOGIN', function (args) {