mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-12 12:25:20 +00:00
fix: user channels issue
This commit is contained in:
parent
6fe737bf8f
commit
5c2df97f04
2 changed files with 38 additions and 19 deletions
|
|
@ -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})` : ''}`;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue