mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Cancel debounced chat save before clearing chat
This commit is contained in:
@ -1979,7 +1979,19 @@ export async function printMessages() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cancels the debounced chat save if it is currently pending.
|
||||||
|
*/
|
||||||
|
export function cancelDebouncedChatSave() {
|
||||||
|
if (chatSaveTimeout) {
|
||||||
|
console.debug('Debounced chat save cancelled');
|
||||||
|
clearTimeout(chatSaveTimeout);
|
||||||
|
chatSaveTimeout = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export async function clearChat() {
|
export async function clearChat() {
|
||||||
|
cancelDebouncedChatSave();
|
||||||
closeMessageEditor();
|
closeMessageEditor();
|
||||||
extension_prompts = {};
|
extension_prompts = {};
|
||||||
if (is_delete_mode) {
|
if (is_delete_mode) {
|
||||||
@ -6929,11 +6941,7 @@ export function saveChatDebounced() {
|
|||||||
const chid = this_chid;
|
const chid = this_chid;
|
||||||
const selectedGroup = selected_group;
|
const selectedGroup = selected_group;
|
||||||
|
|
||||||
if (chatSaveTimeout) {
|
cancelDebouncedChatSave();
|
||||||
console.debug('Clearing chat save timeout');
|
|
||||||
clearTimeout(chatSaveTimeout);
|
|
||||||
chatSaveTimeout = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
chatSaveTimeout = setTimeout(async () => {
|
chatSaveTimeout = setTimeout(async () => {
|
||||||
if (selectedGroup !== selected_group) {
|
if (selectedGroup !== selected_group) {
|
||||||
@ -8646,11 +8654,7 @@ export async function saveChatConditional() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (chatSaveTimeout) {
|
cancelDebouncedChatSave();
|
||||||
console.debug('Debounced chat save canceled');
|
|
||||||
clearTimeout(chatSaveTimeout);
|
|
||||||
chatSaveTimeout = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
isChatSaving = true;
|
isChatSaving = true;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user