Update dupe character to use new popup

This commit is contained in:
Cohee 2024-06-25 21:34:08 +03:00
parent d0f59edf09
commit 083ea43971
2 changed files with 11 additions and 9 deletions

View File

@ -4728,17 +4728,14 @@ function addChatsSeparator(mesSendString) {
} }
} }
async function DupeChar() { async function duplicateCharacter() {
if (!this_chid) { if (!this_chid) {
toastr.warning('You must first select a character to duplicate!'); toastr.warning('You must first select a character to duplicate!');
return ''; return '';
} }
const confirmMessage = ` const confirmMessage = $(await renderTemplateAsync('duplicateConfirm'));
<h3>Are you sure you want to duplicate this character?</h3> const confirm = await callGenericPopup(confirmMessage, POPUP_TYPE.CONFIRM);
<span>If you just want to start a new chat with the same character, use "Start new chat" option in the bottom-left options menu.</span><br><br>`;
const confirm = await callPopup(confirmMessage, 'confirm');
if (!confirm) { if (!confirm) {
console.log('User cancelled duplication'); console.log('User cancelled duplication');
@ -4755,7 +4752,7 @@ async function DupeChar() {
toastr.success('Character Duplicated'); toastr.success('Character Duplicated');
const data = await response.json(); const data = await response.json();
await eventSource.emit(event_types.CHARACTER_DUPLICATED, { oldAvatar: body.avatar_url, newAvatar: data.path }); await eventSource.emit(event_types.CHARACTER_DUPLICATED, { oldAvatar: body.avatar_url, newAvatar: data.path });
getCharacters(); await getCharacters();
} }
return ''; return '';
@ -8807,7 +8804,7 @@ jQuery(async function () {
SlashCommandParser.addCommandObject(SlashCommand.fromProps({ SlashCommandParser.addCommandObject(SlashCommand.fromProps({
name: 'dupe', name: 'dupe',
callback: DupeChar, callback: duplicateCharacter,
helpString: 'Duplicates the currently selected character.', helpString: 'Duplicates the currently selected character.',
})); }));
SlashCommandParser.addCommandObject(SlashCommand.fromProps({ SlashCommandParser.addCommandObject(SlashCommand.fromProps({
@ -10244,7 +10241,7 @@ jQuery(async function () {
}); });
$('#dupe_button').click(async function () { $('#dupe_button').click(async function () {
await DupeChar(); await duplicateCharacter();
}); });
$(document).on('click', '.select_chat_block, .bookmark_link, .mes_bookmark', async function () { $(document).on('click', '.select_chat_block, .bookmark_link, .mes_bookmark', async function () {

View File

@ -0,0 +1,5 @@
<div>
<h3>Are you sure you want to duplicate this character?</h3>
<span>If you just want to start a new chat with the same character, use "Start new chat" option in the bottom-left options menu.</span>
<br>
</div>