fix: user channels issue
This commit is contained in:
1 parent
6fe737bf8f
commit
5c2df97f04
2 files changed
+22
-3
No files matched your search
@@ -182,12 +182,18 @@
|
|||||||
|
|
||||||
const initChannels = async () => {
|
const initChannels = async () => {
|
||||||
// default (none), group, dm type
|
// default (none), group, dm type
|
||||||
|
const res = await getChannels(localStorage.token).catch((error) => {
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (res) {
|
||||||
await channels.set(
|
await channels.set(
|
||||||
(await getChannels(localStorage.token)).sort(
|
res.sort(
|
||||||
(a, b) =>
|
(a, b) =>
|
||||||
['', null, 'group', 'dm'].indexOf(a.type) - ['', null, 'group', 'dm'].indexOf(b.type)
|
['', null, 'group', 'dm'].indexOf(a.type) - ['', null, 'group', 'dm'].indexOf(b.type)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const initChatList = async () => {
|
const initChatList = async () => {
|
||||||
|
|||||||
@@ -487,12 +487,19 @@
|
|||||||
|
|
||||||
// handle channel created event
|
// handle channel created event
|
||||||
if (event.data?.type === 'channel:created') {
|
if (event.data?.type === 'channel:created') {
|
||||||
|
const res = await getChannels(localStorage.token).catch(async (error) => {
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (res) {
|
||||||
await channels.set(
|
await channels.set(
|
||||||
(await getChannels(localStorage.token)).sort(
|
res.sort(
|
||||||
(a, b) =>
|
(a, b) =>
|
||||||
['', null, 'group', 'dm'].indexOf(a.type) - ['', null, 'group', 'dm'].indexOf(b.type)
|
['', null, 'group', 'dm'].indexOf(a.type) - ['', null, 'group', 'dm'].indexOf(b.type)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -531,8 +538,13 @@
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
const res = await getChannels(localStorage.token).catch(async (error) => {
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (res) {
|
||||||
await channels.set(
|
await channels.set(
|
||||||
(await getChannels(localStorage.token)).sort(
|
res.sort(
|
||||||
(a, b) =>
|
(a, b) =>
|
||||||
['', null, 'group', 'dm'].indexOf(a.type) -
|
['', null, 'group', 'dm'].indexOf(a.type) -
|
||||||
['', null, 'group', 'dm'].indexOf(b.type)
|
['', null, 'group', 'dm'].indexOf(b.type)
|
||||||
@@ -540,6 +552,7 @@
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (type === 'message') {
|
if (type === 'message') {
|
||||||
const title = `${data?.user?.name}${event?.channel?.type !== 'dm' ? ` (#${event?.channel?.name})` : ''}`;
|
const title = `${data?.user?.name}${event?.channel?.type !== 'dm' ? ` (#${event?.channel?.name})` : ''}`;
|
||||||
|
|||||||
Reference in new issue
Block a user