feat: dm channels
This commit is contained in:
+22
-13
@@ -56,6 +56,7 @@
|
||||
import Spinner from '$lib/components/common/Spinner.svelte';
|
||||
import { getUserSettings } from '$lib/apis/users';
|
||||
import dayjs from 'dayjs';
|
||||
import { getChannels } from '$lib/apis/channels';
|
||||
|
||||
const unregisterServiceWorkers = async () => {
|
||||
if ('serviceWorker' in navigator) {
|
||||
@@ -485,20 +486,28 @@
|
||||
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
|
||||
};
|
||||
if ($channels.find((ch) => ch.id === event.channel_id)) {
|
||||
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;
|
||||
})
|
||||
);
|
||||
return ch;
|
||||
})
|
||||
);
|
||||
} else {
|
||||
await channels.set(
|
||||
(await getChannels(localStorage.token)).sort((a, b) =>
|
||||
a.type === b.type ? 0 : a.type === 'dm' ? 1 : -1
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (type === 'message') {
|
||||
|
||||
Reference in New Issue
Block a user