fix: user channels issue

This commit is contained in:
Timothy Jaeryang Baek 2025-12-04 14:43:23 -05:00
parent 6fe737bf8f
commit 5c2df97f04
2 changed files with 38 additions and 19 deletions

View file

@ -182,12 +182,18 @@
const initChannels = async () => { const initChannels = async () => {
// default (none), group, dm type // default (none), group, dm type
await channels.set( const res = await getChannels(localStorage.token).catch((error) => {
(await getChannels(localStorage.token)).sort( return null;
(a, b) => });
['', null, 'group', 'dm'].indexOf(a.type) - ['', null, 'group', 'dm'].indexOf(b.type)
) if (res) {
); await channels.set(
res.sort(
(a, b) =>
['', null, 'group', 'dm'].indexOf(a.type) - ['', null, 'group', 'dm'].indexOf(b.type)
)
);
}
}; };
const initChatList = async () => { const initChatList = async () => {

View file

@ -487,12 +487,19 @@
// handle channel created event // handle channel created event
if (event.data?.type === 'channel:created') { if (event.data?.type === 'channel:created') {
await channels.set( const res = await getChannels(localStorage.token).catch(async (error) => {
(await getChannels(localStorage.token)).sort( return null;
(a, b) => });
['', null, 'group', 'dm'].indexOf(a.type) - ['', null, 'group', 'dm'].indexOf(b.type)
) if (res) {
); await channels.set(
res.sort(
(a, b) =>
['', null, 'group', 'dm'].indexOf(a.type) - ['', null, 'group', 'dm'].indexOf(b.type)
)
);
}
return; return;
} }
@ -531,13 +538,19 @@
}) })
); );
} else { } else {
await channels.set( const res = await getChannels(localStorage.token).catch(async (error) => {
(await getChannels(localStorage.token)).sort( return null;
(a, b) => });
['', null, 'group', 'dm'].indexOf(a.type) -
['', null, 'group', 'dm'].indexOf(b.type) if (res) {
) await channels.set(
); res.sort(
(a, b) =>
['', null, 'group', 'dm'].indexOf(a.type) -
['', null, 'group', 'dm'].indexOf(b.type)
)
);
}
} }
} }