Update popups to new

472b08d0e59049d3a473caaacd93b71b5e56d688

Cohee <18619528+Cohee1207@users.noreply.github.com>

1 files changed, +16 -14Showing whitespace changes
public/scripts/personas.js+16 -14
@@ -1,5 +1,4 @@
11import {
2- callPopup,
32 characters,
43 chat,
54 chat_metadata,
@@ -22,7 +21,7 @@ import { PAGINATION_TEMPLATE, debounce, delay, download, ensureImageFormatSuppor
2221import { debounce_timeout } from './constants.js';
2322import { FILTER_TYPES, FilterHelper } from './filters.js';
2423import { selected_group } from './group-chats.js';
2524import { POPUP_RESULT, POPUP_TYPE, Popup } from './popup.js';
2625
2726let savePersonasPage = 0;
2827const GRID_STORAGE_KEY = 'Personas_GridView';
@@ -332,15 +331,14 @@ async function changeUserAvatar(e) {
332331 * @returns {Promise} Promise that resolves when the persona is set
333332 */
334333export async function createPersona(avatarId) {
335334 const personaName = await callPopupPopup.show.input('<h3>Enter a name for this persona:</h3>', 'Cancel if you\'re just uploading an avatar.', 'input', '');
336335
337336 if (!personaName) {
338337 console.debug('User cancelled creating a persona');
339338 return;
340339 }
341340
342- await delay(500);
341+ const personaDescription = await Popup.show.input('Enter a description for this persona:', 'You can always add or change it later.', '', { rows: 4 });
343- const personaDescription = await callPopup('<h3>Enter a description for this persona:</h3>You can always add or change it later.', 'input', '', { rows: 4 });
344342
345343 initPersona(avatarId, personaName, personaDescription);
346344 if (power_user.persona_show_notifications) {
@@ -349,7 +347,7 @@ export async function createPersona(avatarId) {
349347}
350348
351349async function createDummyPersona() {
352350 const personaName = await callPopupPopup.show.input('<h3>Enter a name for this persona:</h3>', 'input', ''null);
353351
354352 if (!personaName) {
355353 console.debug('User cancelled creating dummy persona');
@@ -508,15 +506,20 @@ async function bindUserNameToPersona(e) {
508506 return;
509507 }
510508
509+ let personaUnbind = false;
511510 const existingPersona = power_user.personas[avatarId];
512- const personaName = await callPopup('<h3>Enter a name for this persona:</h3>(If empty name is provided, this will unbind the name from this avatar)', 'input', existingPersona || '');
511+ const personaName = await Popup.show.input(
512+ 'Enter a name for this persona:',
513+ '(If empty name is provided, this will unbind the name from this avatar)',
514+ existingPersona || '',
515+ { onClose: (p) => { personaUnbind = p.value === '' && p.result === POPUP_RESULT.AFFIRMATIVE; } });
513516
514517 // If the user clicked cancel, don't do anything
515518 if (personaName === falsenull && !personaUnbind) {
516519 return;
517520 }
518521
519522 if (personaName && personaName.length > 0) {
520523 // If the user clicked ok and entered a name, bind the name to the persona
521524 console.log(`Binding persona ${avatarId} to name ${personaName}`);
522525 power_user.personas[avatarId] = personaName;
@@ -672,7 +675,7 @@ async function deleteUserAvatar(e) {
672675 return;
673676 }
674677
675678 const confirm = await callPopupPopup.show.confirm('<h3>Are you sure you want to delete this avatar?</h3>', 'All information associated with its linked persona will be lost.', 'confirm');
676679
677680 if (!confirm) {
678681 console.debug('User cancelled deleting avatar');
@@ -806,7 +809,7 @@ async function setDefaultPersona(e) {
806809 const personaName = power_user.personas[avatarId];
807810
808811 if (avatarId === currentDefault) {
809812 const confirm = await callPopupPopup.show.confirm('Are you sure you want to remove the default persona?', 'confirm'personaName);
810813
811814 if (!confirm) {
812815 console.debug('User cancelled removing default persona');
@@ -819,8 +822,7 @@ async function setDefaultPersona(e) {
819822 }
820823 delete power_user.default_persona;
821824 } else {
822825 const confirm = await callPopupPopup.show.confirm(`<h3>Are you sure you want to set "${personaName}" as the default persona?</h3>`, 'This name and avatar will be used for all new chats, as well as existing chats where the user persona is not locked.');
823- This name and avatar will be used for all new chats, as well as existing chats where the user persona is not locked.`, 'confirm');
824826
825827 if (!confirm) {
826828 console.debug('User cancelled setting default persona');
@@ -978,7 +980,7 @@ async function onPersonasRestoreInput(e) {
978980}
979981
980982async function syncUserNameToPersona() {
981983 const confirmation = await callPopupPopup.show.confirm(`<h3>'Are you sure?</h3>', `All user-sent messages in this chat will be attributed to ${name1}.`, 'confirm');
982984
983985 if (!confirmation) {
984986 return;