From 6cfac8a6aa1c7146a5931e761e051115c515670f Mon Sep 17 00:00:00 2001
From: hippoz <10706925-hippoz@users.noreply.gitlab.com>
Date: Wed, 27 Apr 2022 23:41:50 +0300
Subject: [PATCH] frontend: fix behavior when no channels are present
---
frontend/src/components/Main.svelte | 4 ++--
frontend/src/stores.js | 4 +++-
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/frontend/src/components/Main.svelte b/frontend/src/components/Main.svelte
index 3d91135..2107dd6 100644
--- a/frontend/src/components/Main.svelte
+++ b/frontend/src/components/Main.svelte
@@ -26,10 +26,10 @@
{/if}
- {#if $showSidebar}
+ {#if $showSidebar || $selectedChannel.id === -1}
{/if}
- {#if !($smallViewport && $showSidebar) && $showChannelView}
+ {#if !($smallViewport && $showSidebar) && $showChannelView && $selectedChannel.id !== -1}
{/if}
diff --git a/frontend/src/stores.js b/frontend/src/stores.js
index 057e9aa..6e6b1e8 100644
--- a/frontend/src/stores.js
+++ b/frontend/src/stores.js
@@ -36,7 +36,9 @@ class ChannelsStore extends Store {
gateway.subscribe(GatewayEventType.Ready, ({ channels }) => {
this.value = channels;
- selectedChannel.set(channels.length ? channels[0] : null);
+ if (channels.length >= 1) {
+ selectedChannel.set(channels[0]);
+ }
this.updated();
});
gateway.subscribe(GatewayEventType.ChannelCreate, (channel) => {