mirror of
https://github.com/open-webui/open-webui.git
synced 2026-10-28 06:22:33 +00:00
fix: shared chat pages keep reloading and jump back to the bottom (#32725)
Since 0.12.3, any chat opened under /s/, whether through a share link or by an admin viewing another user's chat, was fetched again and again from the moment it opened, and each fetch scrolled the page to the bottom. Scrolling up was impossible and older messages never loaded. The chat is now loaded once when the page opens. Fixes #32657
This commit is contained in:
parent
2bebbb44e1
commit
c4153a6eea
1 changed files with 20 additions and 17 deletions
|
|
@ -48,30 +48,33 @@
|
|||
$sessionUser &&
|
||||
($sessionUser.role === 'admin' || ($sessionUser.permissions?.chat?.import ?? true));
|
||||
|
||||
// Reading history here would rerun this on every history change.
|
||||
$: if ($page.params.id) {
|
||||
(async () => {
|
||||
if (await loadSharedChat()) {
|
||||
loaded = true;
|
||||
await tick();
|
||||
const target = $page.url.searchParams.get('message');
|
||||
if (target && history.messages[target]) {
|
||||
autoScroll = false;
|
||||
history.currentId = getDeepestChildId(history, target);
|
||||
await tick();
|
||||
await messagesComponent?.scrollToMessage(target);
|
||||
} else messagesComponent?.scrollToBottom();
|
||||
} else if (localStorage.token) {
|
||||
await goto('/');
|
||||
} else {
|
||||
await goto(`/auth?redirect=${encodeURIComponent($page.url.pathname)}`);
|
||||
}
|
||||
})();
|
||||
loadAndScroll();
|
||||
}
|
||||
|
||||
//////////////////////////
|
||||
// Web functions
|
||||
//////////////////////////
|
||||
|
||||
const loadAndScroll = async () => {
|
||||
if (await loadSharedChat()) {
|
||||
loaded = true;
|
||||
await tick();
|
||||
const target = $page.url.searchParams.get('message');
|
||||
if (target && history.messages[target]) {
|
||||
autoScroll = false;
|
||||
history.currentId = getDeepestChildId(history, target);
|
||||
await tick();
|
||||
await messagesComponent?.scrollToMessage(target);
|
||||
} else messagesComponent?.scrollToBottom();
|
||||
} else if (localStorage.token) {
|
||||
await goto('/');
|
||||
} else {
|
||||
await goto(`/auth?redirect=${encodeURIComponent($page.url.pathname)}`);
|
||||
}
|
||||
};
|
||||
|
||||
const loadSharedChat = async () => {
|
||||
const token = localStorage.token ?? '';
|
||||
const shareId = $page.params.id;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue