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