Cancel debounced chat save if regular save is performed

This commit is contained in:
Cohee
2025-02-25 21:38:24 +02:00
parent 5545a425ea
commit 422517ec93
2 changed files with 9 additions and 2 deletions

View File

@ -6436,6 +6436,7 @@ export function saveChatDebounced() {
if (chatSaveTimeout) {
console.debug('Clearing chat save timeout');
clearTimeout(chatSaveTimeout);
chatSaveTimeout = null;
}
chatSaveTimeout = setTimeout(async () => {
@ -6452,7 +6453,7 @@ export function saveChatDebounced() {
console.debug('Chat save timeout triggered');
await saveChatConditional();
console.debug('Chat saved');
}, 1000);
}, DEFAULT_SAVE_EDIT_TIMEOUT);
}
export async function saveChat(chatName, withMetadata, mesId) {
@ -8067,6 +8068,12 @@ export async function saveChatConditional() {
}
try {
if (chatSaveTimeout) {
console.debug('Debounced chat save canceled');
clearTimeout(chatSaveTimeout);
chatSaveTimeout = null;
}
isChatSaving = true;
if (selected_group) {

View File

@ -1048,7 +1048,7 @@ function registerReasoningAppEvents() {
if (contentUpdated) {
syncMesToSwipe();
await saveChatConditional();
saveChatDebounced();
// Find if a message already exists in DOM and must be updated
const messageRendered = document.querySelector(`.mes[mesid="${idx}"]`) !== null;