diff --git a/src/lib/components/channel/Channel.svelte b/src/lib/components/channel/Channel.svelte index 1bfd03d97..34f081158 100644 --- a/src/lib/components/channel/Channel.svelte +++ b/src/lib/components/channel/Channel.svelte @@ -2,7 +2,7 @@ import { toast } from 'svelte-sonner'; import { onDestroy, onMount, tick } from 'svelte'; - import { showSidebar, socket } from '$lib/stores'; + import { chatId, showSidebar, socket } from '$lib/stores'; import { getChannelById, getChannelMessages, sendMessage } from '$lib/apis/channels'; import Messages from './Messages.svelte'; @@ -98,6 +98,10 @@ }; onMount(() => { + if ($chatId) { + chatId.set(''); + } + $socket?.on('channel-events', channelEventHandler); }); diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index 896d1fef4..d4fb46b9e 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -96,7 +96,7 @@ const chat = $page.url.pathname.includes(`/c/${event.chat_id}`); if ( - (!(chat || event.chat_id === $chatId) && !$temporaryChatEnabled) || + (event.chat_id !== $chatId && !$temporaryChatEnabled) || document.visibilityState !== 'visible' ) { await tick();