This commit is contained in:
Timothy Jaeryang Baek 2025-11-27 08:07:39 -05:00
parent 560702a8f7
commit 6bb204eb80
3 changed files with 8 additions and 3 deletions

View file

@ -5,7 +5,7 @@
import { onDestroy, onMount, tick } from 'svelte';
import { goto } from '$app/navigation';
import { chatId, showSidebar, socket, user } from '$lib/stores';
import { chatId, channelId as _channelId, showSidebar, socket, user } from '$lib/stores';
import { getChannelById, getChannelMessages, sendMessage } from '$lib/apis/channels';
import Messages from './Messages.svelte';
@ -62,6 +62,7 @@
currentId = id;
updateLastReadAt(id);
_channelId.set(id);
top = false;
messages = null;
@ -220,6 +221,7 @@
onDestroy(() => {
// last read at
updateLastReadAt(id);
_channelId.set(null);
$socket?.off('events:channel', channelEventHandler);
});
</script>

View file

@ -51,6 +51,8 @@ export const chatId = writable('');
export const chatTitle = writable('');
export const channels = writable([]);
export const channelId = writable(null);
export const chats = writable(null);
export const pinnedChats = writable([]);
export const tags = writable([]);

View file

@ -29,7 +29,8 @@
appInfo,
toolServers,
playingNotificationSound,
channels
channels,
channelId
} from '$lib/stores';
import { goto } from '$app/navigation';
import { page } from '$app/stores';
@ -486,7 +487,7 @@
const data = event?.data?.data ?? null;
if ($channels) {
if ($channels.find((ch) => ch.id === event.channel_id)) {
if ($channels.find((ch) => ch.id === event.channel_id) && $channelId !== event.channel_id) {
channels.set(
$channels.map((ch) => {
if (ch.id === event.channel_id) {