mirror of
https://github.com/open-webui/open-webui.git
synced 2026-07-18 19:29:11 -05:00
refac
This commit is contained in:
@@ -184,6 +184,12 @@
|
||||
navigateHandler();
|
||||
}
|
||||
|
||||
let saveControlsTimer;
|
||||
$: if (!loading && !$temporaryChatEnabled && $chatId && params && chatFiles) {
|
||||
clearTimeout(saveControlsTimer);
|
||||
saveControlsTimer = setTimeout(saveControls, 400);
|
||||
}
|
||||
|
||||
const navigateHandler = async () => {
|
||||
// Mark the outgoing chat as read before loading the new one.
|
||||
// $chatId still holds the previous chat here — loadChat() updates it.
|
||||
@@ -191,6 +197,8 @@
|
||||
updateLastReadAt($chatId);
|
||||
}
|
||||
|
||||
clearTimeout(saveControlsTimer);
|
||||
await saveControls();
|
||||
loading = true;
|
||||
|
||||
prompt = '';
|
||||
@@ -811,6 +819,8 @@
|
||||
|
||||
return () => {
|
||||
try {
|
||||
clearTimeout(saveControlsTimer);
|
||||
saveControls();
|
||||
if (chatIdProp && !$temporaryChatEnabled) {
|
||||
updateLastReadAt(chatIdProp);
|
||||
}
|
||||
@@ -2758,6 +2768,13 @@
|
||||
}
|
||||
};
|
||||
|
||||
const saveControls = async () => {
|
||||
if (!$chatId || $temporaryChatEnabled) return;
|
||||
await updateChatById(localStorage.token, $chatId, { params, files: chatFiles }).catch(
|
||||
(err) => console.error('[controls autosave]', err)
|
||||
);
|
||||
};
|
||||
|
||||
const MAX_DRAFT_LENGTH = 5000;
|
||||
let saveDraftTimeout: ReturnType<typeof setTimeout> | null = null;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user