fix bogus "messages failed to load" after logging out

This commit is contained in:
hippoz 2022-08-03 02:46:48 +03:00
parent 6d76dec265
commit 954c5bd540
No known key found for this signature in database
GPG key ID: 7C52899193467641

View file

@ -246,7 +246,7 @@ class MessageStore extends Store {
} }
async doInitialLoad() { async doInitialLoad() {
if (this.channelId === -1) if (this.channelId === -1 || !getItem("auth:token") || getItem("auth:token").length < 1)
return; return;
await this.loadOlderMessages(); 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 showSidebar = new Store(true, "showSidebar");
export const smallViewport = new Store(false, "smallViewport"); export const smallViewport = new Store(false, "smallViewport");
export const showChannelView = new Store(true, "showChannelView"); export const showChannelView = new Store(true, "showChannelView");
@ -352,3 +352,7 @@ export const allStores = {
selectedChannel.watch((newSelectedChannel) => { selectedChannel.watch((newSelectedChannel) => {
setItem("app:cache:openChannelId", newSelectedChannel.id); setItem("app:cache:openChannelId", newSelectedChannel.id);
}); });
gateway.subscribe(GatewayEventType.Authenticate, () => {
selectedChannel.set("app:cache:openChannelId");
});