Prevent 'no such file or directory' error when mass deleting characters

This commit is contained in:
artisticMink
2023-12-09 14:36:37 +01:00
parent 4692450975
commit dfd41a110a

View File

@ -6,7 +6,7 @@ import {
deleteCharacter,
event_types,
eventSource,
getCharacters,
getCharacters, getPastCharacterChats,
getRequestHeaders,
printCharacters,
this_chid,
@ -124,26 +124,15 @@ class CharacterContextMenu {
}).then(response => {
if (response.ok) {
return deleteCharacter(character.name, character.avatar, false).then(() => {
if (deleteChats) {
return fetch('/api/characters/chats', {
method: 'POST',
body: JSON.stringify({ avatar_url: character.avatar }),
headers: getRequestHeaders(),
}).then((response) => {
let data = response.json();
data = Object.values(data);
const pastChats = data.sort((a, b) => a['file_name'].localeCompare(b['file_name'])).reverse();
eventSource.emit('characterDeleted', {id: characterId, character: characters[characterId]});
if (deleteChats) getPastCharacterChats(characterId).then(pastChats => {
for (const chat of pastChats) {
const name = chat.file_name.replace('.jsonl', '');
eventSource.emit(event_types.CHAT_DELETED, name);
}
});
}
});
}
eventSource.emit('characterDeleted', { id: this_chid, character: characters[this_chid] });
});
};
@ -626,12 +615,11 @@ class BulkEditOverlay {
showLoader();
toastr.info('We\'re deleting your characters, please wait...', 'Working on it');
Promise.all(this.selectedCharacters.map(async characterId => CharacterContextMenu.delete(characterId, deleteChats)))
Promise.allSettled(this.selectedCharacters.map(async characterId => CharacterContextMenu.delete(characterId, deleteChats)))
.then(() => getCharacters())
.then(() => this.browseState())
.finally(() => hideLoader());
},
);
});
};
/**