From 954c5bd5401056f88b5f1a88a26b3b8dda13aa40 Mon Sep 17 00:00:00 2001 From: hippoz <10706925-hippoz@users.noreply.gitlab.com> Date: Wed, 3 Aug 2022 02:46:48 +0300 Subject: [PATCH] fix bogus "messages failed to load" after logging out --- frontend/src/stores.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/frontend/src/stores.js b/frontend/src/stores.js index 09f4f31..90e0b55 100644 --- a/frontend/src/stores.js +++ b/frontend/src/stores.js @@ -246,7 +246,7 @@ class MessageStore extends Store { } async doInitialLoad() { - if (this.channelId === -1) + if (this.channelId === -1 || !getItem("auth:token") || getItem("auth:token").length < 1) return; await this.loadOlderMessages(); @@ -323,7 +323,7 @@ class OverlayStore extends Store { } } -export const selectedChannel = new Store({ id: getItem("app:cache:openChannelId"), name: "none", creator_id: -1 }, "selectedChannel"); +export const selectedChannel = new Store({ id: -1, name: "none", creator_id: -1 }, "selectedChannel"); export const showSidebar = new Store(true, "showSidebar"); export const smallViewport = new Store(false, "smallViewport"); export const showChannelView = new Store(true, "showChannelView"); @@ -352,3 +352,7 @@ export const allStores = { selectedChannel.watch((newSelectedChannel) => { setItem("app:cache:openChannelId", newSelectedChannel.id); }); + +gateway.subscribe(GatewayEventType.Authenticate, () => { + selectedChannel.set("app:cache:openChannelId"); +});