Switch char deletion to new popup
- New popup - Move char CHARACTER_DELETED to after char deleting, and inside the correct function
This commit is contained in:
parent
d64d16bdf2
commit
360c2985f5
|
@ -8659,13 +8659,11 @@ function doCloseChat() {
|
||||||
* it proceeds to delete character from UI and saves settings.
|
* it proceeds to delete character from UI and saves settings.
|
||||||
* In case of error during the fetch request, it logs the error details.
|
* In case of error during the fetch request, it logs the error details.
|
||||||
*
|
*
|
||||||
* @param {string} popup_type - The type of popup currently active.
|
|
||||||
* @param {string} this_chid - The character ID to be deleted.
|
* @param {string} this_chid - The character ID to be deleted.
|
||||||
* @param {boolean} delete_chats - Whether to delete chats or not.
|
* @param {boolean} delete_chats - Whether to delete chats or not.
|
||||||
*/
|
*/
|
||||||
export async function handleDeleteCharacter(popup_type, this_chid, delete_chats) {
|
export async function handleDeleteCharacter(this_chid, delete_chats) {
|
||||||
if (popup_type !== 'del_ch' ||
|
if (!characters[this_chid]) {
|
||||||
!characters[this_chid]) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8711,6 +8709,8 @@ export async function deleteCharacter(characterKey, { deleteChats = true } = {})
|
||||||
await eventSource.emit(event_types.CHAT_DELETED, name);
|
await eventSource.emit(event_types.CHAT_DELETED, name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
eventSource.emit(event_types.CHARACTER_DELETED, { id: this_chid, character: characters[this_chid] });
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -9212,11 +9212,6 @@ jQuery(async function () {
|
||||||
}, 2000);
|
}, 2000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (popup_type == 'del_ch') {
|
|
||||||
const deleteChats = !!$('#del_char_checkbox').prop('checked');
|
|
||||||
eventSource.emit(event_types.CHARACTER_DELETED, { id: this_chid, character: characters[this_chid] });
|
|
||||||
await handleDeleteCharacter(popup_type, this_chid, deleteChats);
|
|
||||||
}
|
|
||||||
if (popup_type == 'alternate_greeting' && menu_type !== 'create') {
|
if (popup_type == 'alternate_greeting' && menu_type !== 'create') {
|
||||||
createOrEditCharacter();
|
createOrEditCharacter();
|
||||||
}
|
}
|
||||||
|
@ -9297,15 +9292,27 @@ jQuery(async function () {
|
||||||
|
|
||||||
$('#form_create').submit(createOrEditCharacter);
|
$('#form_create').submit(createOrEditCharacter);
|
||||||
|
|
||||||
$('#delete_button').on('click', function () {
|
$('#delete_button').on('click', async function () {
|
||||||
callPopup(`
|
if (!this_chid) {
|
||||||
<h3>Delete the character?</h3>
|
toastr.warning('No character selected.');
|
||||||
<b>THIS IS PERMANENT!<br><br>
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let deleteChats = false;
|
||||||
|
|
||||||
|
const confirm = await Popup.show.confirm('Delete the character?', `
|
||||||
|
<b>THIS IS PERMANENT!<br><br>
|
||||||
<label for="del_char_checkbox" class="checkbox_label justifyCenter">
|
<label for="del_char_checkbox" class="checkbox_label justifyCenter">
|
||||||
<input type="checkbox" id="del_char_checkbox" />
|
<input type="checkbox" id="del_char_checkbox" />
|
||||||
<small>Also delete the chat files</small>
|
<small>Also delete the chat files</small>
|
||||||
</label><br></b>`, 'del_ch', '',
|
</label><br></b>`, {
|
||||||
);
|
onClose: () => deleteChats = !!$('#del_char_checkbox').prop('checked'),
|
||||||
|
});
|
||||||
|
if (!confirm) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await deleteCharacter(characters[this_chid].avatar, { deleteChats: deleteChats });
|
||||||
});
|
});
|
||||||
|
|
||||||
//////// OPTIMIZED ALL CHAR CREATION/EDITING TEXTAREA LISTENERS ///////////////
|
//////// OPTIMIZED ALL CHAR CREATION/EDITING TEXTAREA LISTENERS ///////////////
|
||||||
|
|
Loading…
Reference in New Issue