feat/enh: channels unread messages count
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user