feat/enh: channels unread messages count

This commit is contained in:
Timothy Jaeryang Baek
2025-11-27 04:31:04 -05:00
parent c7a48c50a3
commit 64b4d5d9c2
8 changed files with 463 additions and 26 deletions
+19 -1
View File
@@ -28,7 +28,8 @@
isApp,
appInfo,
toolServers,
playingNotificationSound
playingNotificationSound,
channels
} from '$lib/stores';
import { goto } from '$app/navigation';
import { page } from '$app/stores';
@@ -483,6 +484,23 @@
const type = event?.data?.type ?? null;
const data = event?.data?.data ?? null;
if ($channels) {
channels.set(
$channels.map((ch) => {
if (ch.id === event.channel_id) {
if (type === 'message') {
return {
...ch,
unread_count: (ch.unread_count ?? 0) + 1,
last_message_at: event.created_at
};
}
}
return ch;
})
);
}
if (type === 'message') {
if ($isLastActiveTab) {
if ($settings?.notificationEnabled ?? false) {