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