mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Cancel debounced chat save if regular save is performed
This commit is contained in:
@ -6436,6 +6436,7 @@ export function saveChatDebounced() {
|
|||||||
if (chatSaveTimeout) {
|
if (chatSaveTimeout) {
|
||||||
console.debug('Clearing chat save timeout');
|
console.debug('Clearing chat save timeout');
|
||||||
clearTimeout(chatSaveTimeout);
|
clearTimeout(chatSaveTimeout);
|
||||||
|
chatSaveTimeout = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
chatSaveTimeout = setTimeout(async () => {
|
chatSaveTimeout = setTimeout(async () => {
|
||||||
@ -6452,7 +6453,7 @@ export function saveChatDebounced() {
|
|||||||
console.debug('Chat save timeout triggered');
|
console.debug('Chat save timeout triggered');
|
||||||
await saveChatConditional();
|
await saveChatConditional();
|
||||||
console.debug('Chat saved');
|
console.debug('Chat saved');
|
||||||
}, 1000);
|
}, DEFAULT_SAVE_EDIT_TIMEOUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function saveChat(chatName, withMetadata, mesId) {
|
export async function saveChat(chatName, withMetadata, mesId) {
|
||||||
@ -8067,6 +8068,12 @@ export async function saveChatConditional() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
if (chatSaveTimeout) {
|
||||||
|
console.debug('Debounced chat save canceled');
|
||||||
|
clearTimeout(chatSaveTimeout);
|
||||||
|
chatSaveTimeout = null;
|
||||||
|
}
|
||||||
|
|
||||||
isChatSaving = true;
|
isChatSaving = true;
|
||||||
|
|
||||||
if (selected_group) {
|
if (selected_group) {
|
||||||
|
@ -1048,7 +1048,7 @@ function registerReasoningAppEvents() {
|
|||||||
|
|
||||||
if (contentUpdated) {
|
if (contentUpdated) {
|
||||||
syncMesToSwipe();
|
syncMesToSwipe();
|
||||||
await saveChatConditional();
|
saveChatDebounced();
|
||||||
|
|
||||||
// Find if a message already exists in DOM and must be updated
|
// Find if a message already exists in DOM and must be updated
|
||||||
const messageRendered = document.querySelector(`.mes[mesid="${idx}"]`) !== null;
|
const messageRendered = document.querySelector(`.mes[mesid="${idx}"]`) !== null;
|
||||||
|
Reference in New Issue
Block a user