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 () => {
// default (none), group, dm type
await channels.set(
(await getChannels(localStorage.token)).sort(
(a, b) =>
['', null, 'group', 'dm'].indexOf(a.type) - ['', null, 'group', 'dm'].indexOf(b.type)
)
);
const res = await getChannels(localStorage.token).catch((error) => {
return null;
});
if (res) {
await channels.set(
res.sort(
(a, b) =>
['', null, 'group', 'dm'].indexOf(a.type) - ['', null, 'group', 'dm'].indexOf(b.type)
)
);
}
};
const initChatList = async () => {

View file

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