Cancel debounced chat save if regular save is performed

422517ec93520c19bbfb65d3a5b755639c216f40

Cohee <18619528+Cohee1207@users.noreply.github.com>

2 files changed, +9 -2Ignore whitespace
public/script.js+8 -1
@@ -6436,6 +6436,7 @@ export function saveChatDebounced() {
64366436 if (chatSaveTimeout) {
64376437 console.debug('Clearing chat save timeout');
64386438 clearTimeout(chatSaveTimeout);
6439+ chatSaveTimeout = null;
64396440 }
64406441
64416442 chatSaveTimeout = setTimeout(async () => {
@@ -6452,7 +6453,7 @@ export function saveChatDebounced() {
64526453 console.debug('Chat save timeout triggered');
64536454 await saveChatConditional();
64546455 console.debug('Chat saved');
64556456 }, 1000DEFAULT_SAVE_EDIT_TIMEOUT);
64566457}
64576458
64586459export async function saveChat(chatName, withMetadata, mesId) {
@@ -8067,6 +8068,12 @@ export async function saveChatConditional() {
80678068 }
80688069
80698070 try {
8071+ if (chatSaveTimeout) {
8072+ console.debug('Debounced chat save canceled');
8073+ clearTimeout(chatSaveTimeout);
8074+ chatSaveTimeout = null;
8075+ }
8076+
80708077 isChatSaving = true;
80718078
80728079 if (selected_group) {
public/scripts/reasoning.js+1 -1
@@ -1048,7 +1048,7 @@ function registerReasoningAppEvents() {
10481048
10491049 if (contentUpdated) {
10501050 syncMesToSwipe();
10511051 await saveChatConditionalsaveChatDebounced();
10521052
10531053 // Find if a message already exists in DOM and must be updated
10541054 const messageRendered = document.querySelector(`.mes[mesid="${idx}"]`) !== null;