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 @@
1import {1import {
2 callPopup,
3 characters,2 characters,
4 chat,3 chat,
5 chat_metadata,4 chat_metadata,
@@ -22,7 +21,7 @@ import { PAGINATION_TEMPLATE, debounce, delay, download, ensureImageFormatSuppor
22import { debounce_timeout } from './constants.js';21import { debounce_timeout } from './constants.js';
23import { FILTER_TYPES, FilterHelper } from './filters.js';22import { FILTER_TYPES, FilterHelper } from './filters.js';
24import { selected_group } from './group-chats.js';23import { selected_group } from './group-chats.js';
25import { POPUP_TYPE, Popup } from './popup.js';24import { POPUP_RESULT, POPUP_TYPE, Popup } from './popup.js';
2625
27let savePersonasPage = 0;26let savePersonasPage = 0;
28const GRID_STORAGE_KEY = 'Personas_GridView';27const GRID_STORAGE_KEY = 'Personas_GridView';
@@ -332,15 +331,14 @@ async function changeUserAvatar(e) {
332 * @returns {Promise} Promise that resolves when the persona is set331 * @returns {Promise} Promise that resolves when the persona is set
333 */332 */
334export async function createPersona(avatarId) {333export async function createPersona(avatarId) {
335 const personaName = await callPopup('<h3>Enter a name for this persona:</h3>Cancel if you\'re just uploading an avatar.', 'input', '');334 const personaName = await Popup.show.input('Enter a name for this persona:', 'Cancel if you\'re just uploading an avatar.', '');
336335
337 if (!personaName) {336 if (!personaName) {
338 console.debug('User cancelled creating a persona');337 console.debug('User cancelled creating a persona');
339 return;338 return;
340 }339 }
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
345 initPersona(avatarId, personaName, personaDescription);343 initPersona(avatarId, personaName, personaDescription);
346 if (power_user.persona_show_notifications) {344 if (power_user.persona_show_notifications) {
@@ -349,7 +347,7 @@ export async function createPersona(avatarId) {
349}347}
350348
351async function createDummyPersona() {349async function createDummyPersona() {
352 const personaName = await callPopup('<h3>Enter a name for this persona:</h3>', 'input', '');350 const personaName = await Popup.show.input('Enter a name for this persona:', null);
353351
354 if (!personaName) {352 if (!personaName) {
355 console.debug('User cancelled creating dummy persona');353 console.debug('User cancelled creating dummy persona');
@@ -508,15 +506,20 @@ async function bindUserNameToPersona(e) {
508 return;506 return;
509 }507 }
510508
509 let personaUnbind = false;
511 const existingPersona = power_user.personas[avatarId];510 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
514 // If the user clicked cancel, don't do anything517 // If the user clicked cancel, don't do anything
515 if (personaName === false) {518 if (personaName === null && !personaUnbind) {
516 return;519 return;
517 }520 }
518521
519 if (personaName.length > 0) {522 if (personaName && personaName.length > 0) {
520 // If the user clicked ok and entered a name, bind the name to the persona523 // If the user clicked ok and entered a name, bind the name to the persona
521 console.log(`Binding persona ${avatarId} to name ${personaName}`);524 console.log(`Binding persona ${avatarId} to name ${personaName}`);
522 power_user.personas[avatarId] = personaName;525 power_user.personas[avatarId] = personaName;
@@ -672,7 +675,7 @@ async function deleteUserAvatar(e) {
672 return;675 return;
673 }676 }
674677
675 const confirm = await callPopup('<h3>Are you sure you want to delete this avatar?</h3>All information associated with its linked persona will be lost.', 'confirm');678 const confirm = await Popup.show.confirm('Are you sure you want to delete this avatar?', 'All information associated with its linked persona will be lost.');
676679
677 if (!confirm) {680 if (!confirm) {
678 console.debug('User cancelled deleting avatar');681 console.debug('User cancelled deleting avatar');
@@ -806,7 +809,7 @@ async function setDefaultPersona(e) {
806 const personaName = power_user.personas[avatarId];809 const personaName = power_user.personas[avatarId];
807810
808 if (avatarId === currentDefault) {811 if (avatarId === currentDefault) {
809 const confirm = await callPopup('Are you sure you want to remove the default persona?', 'confirm');812 const confirm = await Popup.show.confirm('Are you sure you want to remove the default persona?', personaName);
810813
811 if (!confirm) {814 if (!confirm) {
812 console.debug('User cancelled removing default persona');815 console.debug('User cancelled removing default persona');
@@ -819,8 +822,7 @@ async function setDefaultPersona(e) {
819 }822 }
820 delete power_user.default_persona;823 delete power_user.default_persona;
821 } else {824 } else {
822 const confirm = await callPopup(`<h3>Are you sure you want to set "${personaName}" as the default persona?</h3>825 const confirm = await Popup.show.confirm(`Are you sure you want to set "${personaName}" as the default persona?`, '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
825 if (!confirm) {827 if (!confirm) {
826 console.debug('User cancelled setting default persona');828 console.debug('User cancelled setting default persona');
@@ -978,7 +980,7 @@ async function onPersonasRestoreInput(e) {
978}980}
979981
980async function syncUserNameToPersona() {982async function syncUserNameToPersona() {
981 const confirmation = await callPopup(`<h3>Are you sure?</h3>All user-sent messages in this chat will be attributed to ${name1}.`, 'confirm');983 const confirmation = await Popup.show.confirm('Are you sure?', `All user-sent messages in this chat will be attributed to ${name1}.`);
982984
983 if (!confirmation) {985 if (!confirmation) {
984 return;986 return;