From 32c888c2807f4edc6b756bf1f734f8d520e8b5d3 Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Fri, 28 Nov 2025 01:40:52 -0500 Subject: [PATCH] refac --- src/lib/components/channel/Channel.svelte | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/lib/components/channel/Channel.svelte b/src/lib/components/channel/Channel.svelte index 3caf18bcab..7e4f1f6b7a 100644 --- a/src/lib/components/channel/Channel.svelte +++ b/src/lib/components/channel/Channel.svelte @@ -5,7 +5,14 @@ import { onDestroy, onMount, tick } from 'svelte'; import { goto } from '$app/navigation'; - import { chatId, channelId as _channelId, showSidebar, socket, user } from '$lib/stores'; + import { + chatId, + channels, + channelId as _channelId, + showSidebar, + socket, + user + } from '$lib/stores'; import { getChannelById, getChannelMessages, sendMessage } from '$lib/apis/channels'; import Messages from './Messages.svelte'; @@ -53,6 +60,18 @@ type: 'last_read_at' } }); + + channels.set( + $channels.map((channel) => { + if (channel.id === channelId) { + return { + ...channel, + unread_count: 0 + }; + } + return channel; + }) + ); }; const initHandler = async () => {