This commit is contained in:
Timothy Jaeryang Baek
2025-11-30 14:51:44 -05:00
parent 88decab9be
commit c62609faba
4 changed files with 127 additions and 6 deletions
@@ -3,9 +3,9 @@
const i18n = getContext('i18n');
import { user as _user, socket } from '$lib/stores';
import { user as _user, channels, socket } from '$lib/stores';
import { WEBUI_API_BASE_URL, WEBUI_BASE_URL } from '$lib/constants';
import { getDMChannelByUserId } from '$lib/apis/channels';
import { getChannels, getDMChannelByUserId } from '$lib/apis/channels';
import ChatBubbles from '$lib/components/icons/ChatBubbles.svelte';
import ChatBubble from '$lib/components/icons/ChatBubble.svelte';
@@ -25,7 +25,6 @@
});
if (res) {
$socket.emit('join-channels', { auth: { token: $_user?.token } });
goto(`/channels/${res.id}`);
}
};
+28 -1
View File
@@ -480,10 +480,29 @@
};
const channelEventHandler = async (event) => {
console.log('channelEventHandler', event);
if (event.data?.type === 'typing') {
return;
}
// handle channel created event
if (event.data?.type === 'channel:created') {
await channels.set(
(await getChannels(localStorage.token)).sort((a, b) =>
a.type === b.type
? 0
: a.type === 'dm'
? 1
: a.type === 'group'
? b.type === 'dm'
? -1
: 0
: -1
)
);
return;
}
// check url path
const channel = $page.url.pathname.includes(`/channels/${event.channel_id}`);
@@ -521,7 +540,15 @@
} else {
await channels.set(
(await getChannels(localStorage.token)).sort((a, b) =>
a.type === b.type ? 0 : a.type === 'dm' ? 1 : -1
a.type === b.type
? 0
: a.type === 'dm'
? 1
: a.type === 'group'
? b.type === 'dm'
? -1
: 0
: -1
)
);
}