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() {
6436 if (chatSaveTimeout) {6436 if (chatSaveTimeout) {
6437 console.debug('Clearing chat save timeout');6437 console.debug('Clearing chat save timeout');
6438 clearTimeout(chatSaveTimeout);6438 clearTimeout(chatSaveTimeout);
6439 chatSaveTimeout = null;
6439 }6440 }
64406441
6441 chatSaveTimeout = setTimeout(async () => {6442 chatSaveTimeout = setTimeout(async () => {
@@ -6452,7 +6453,7 @@ export function saveChatDebounced() {
6452 console.debug('Chat save timeout triggered');6453 console.debug('Chat save timeout triggered');
6453 await saveChatConditional();6454 await saveChatConditional();
6454 console.debug('Chat saved');6455 console.debug('Chat saved');
6455 }, 1000);6456 }, DEFAULT_SAVE_EDIT_TIMEOUT);
6456}6457}
64576458
6458export async function saveChat(chatName, withMetadata, mesId) {6459export async function saveChat(chatName, withMetadata, mesId) {
@@ -8067,6 +8068,12 @@ export async function saveChatConditional() {
8067 }8068 }
80688069
8069 try {8070 try {
8071 if (chatSaveTimeout) {
8072 console.debug('Debounced chat save canceled');
8073 clearTimeout(chatSaveTimeout);
8074 chatSaveTimeout = null;
8075 }
8076
8070 isChatSaving = true;8077 isChatSaving = true;
80718078
8072 if (selected_group) {8079 if (selected_group) {
public/scripts/reasoning.js+1 -1
@@ -1048,7 +1048,7 @@ function registerReasoningAppEvents() {
10481048
1049 if (contentUpdated) {1049 if (contentUpdated) {
1050 syncMesToSwipe();1050 syncMesToSwipe();
1051 await saveChatConditional();1051 saveChatDebounced();
10521052
1053 // Find if a message already exists in DOM and must be updated1053 // Find if a message already exists in DOM and must be updated
1054 const messageRendered = document.querySelector(`.mes[mesid="${idx}"]`) !== null;1054 const messageRendered = document.querySelector(`.mes[mesid="${idx}"]`) !== null;