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"); +});