Reduce persona toast spam
| @@ -6737,14 +6737,14 @@ export function changeMainAPI() { | ||
| 6737 | 6737 | forceCharacterEditorTokenize(); |
| 6738 | 6738 | } |
| 6739 | 6739 | |
| 6740 | 6740 | export function setUserName(value, { toastPersonaNameChange = true } = {}) { |
| 6741 | 6741 | name1 = value; |
| 6742 | 6742 | if (name1 === undefined || name1 == '') |
| 6743 | 6743 | name1 = default_user_name; |
| 6744 | 6744 | console.log(`User name changed to ${name1}`); |
| 6745 | 6745 | $('#your_name').val(name1); |
| 6746 | 6746 | if (toastPersonaNameChange && power_user.persona_show_notifications) { |
| 6747 | 6747 | toastr.success(t`Your messages will now be sent as ${name1}`, t`Current personaPersona updatedChanged`); |
| 6748 | 6748 | } |
| 6749 | 6749 | saveSettingsDebounced(); |
| 6750 | 6750 | } |
| @@ -10024,9 +10024,9 @@ jQuery(async function () { | ||
| 10024 | 10024 | |
| 10025 | 10025 | // One of the persona was selected. So load it. |
| 10026 | 10026 | if (!isRemoving && selectedPersona) { |
| 10027 | 10027 | setUserAvatar(selectedPersona, { toastPersonaNameChange: false }); |
| 10028 | 10028 | if (power_user.persona_show_notifications) { |
| 10029 | 10029 | toastr.infosuccess(t`Selected persona ${power_user.personas[selectedPersona]} for current chat.`, t`Connected Persona Selected`); |
| 10030 | 10030 | } |
| 10031 | 10031 | } |
| 10032 | 10032 | }); |
| @@ -73,11 +73,11 @@ export function initUserAvatar(avatar) { | ||
| 73 | 73 | * Sets a user avatar file |
| 74 | 74 | * @param {string} imgfile Link to an image file |
| 75 | 75 | */ |
| 76 | 76 | export function setUserAvatar(imgfile, { toastPersonaNameChange = true } = {}) { |
| 77 | 77 | user_avatar = imgfile && typeof imgfile === 'string' ? imgfile : $(this).attr('imgfile'); |
| 78 | 78 | reloadUserAvatar(); |
| 79 | 79 | highlightSelectedAvatar(); |
| 80 | 80 | selectCurrentPersona({ toastPersonaNameChange: toastPersonaNameChange }); |
| 81 | 81 | saveSettingsDebounced(); |
| 82 | 82 | $('.zoomed_avatar[forchar]').remove(); |
| 83 | 83 | } |
| @@ -628,7 +628,7 @@ export async function askForPersonaSelection(title, text, personas, { okButton = | ||
| 628 | 628 | updatePersonaConnectionsAvatarList(); |
| 629 | 629 | if (power_user.persona_show_notifications) { |
| 630 | 630 | const name = targetedChar.type == 'character' ? characters[targetedChar.id]?.name : groups[targetedChar.id]?.name; |
| 631 | 631 | toastr.info(t`All connections to ${name} have been removed.`, t`Personas unlockedUnlocked`); |
| 632 | 632 | } |
| 633 | 633 | }, |
| 634 | 634 | }); |
| @@ -732,12 +732,14 @@ async function bindUserNameToPersona(e) { | ||
| 732 | 732 | setPersonaDescription(); |
| 733 | 733 | } |
| 734 | 734 | |
| 735 | 735 | function selectCurrentPersona({ toastPersonaNameChange = true } = {}) { |
| 736 | 736 | const personaName = power_user.personas[user_avatar]; |
| 737 | 737 | if (personaName) { |
| 738 | + const shouldAutoLock = power_user.persona_auto_lock && user_avatar !== chat_metadata['persona']; | |
| 739 | + | |
| 738 | 740 | if (personaName !== name1) { |
| 739 | 741 | console.log(`Auto-updating user name to ${personaName}`); |
| 740 | - setUserName(personaName); | |
| 742 | + setUserName(personaName, { toastPersonaNameChange: !shouldAutoLock && toastPersonaNameChange }); | |
| 741 | 743 | } |
| 742 | 744 | |
| 743 | 745 | const descriptor = power_user.persona_descriptions[user_avatar]; |
| @@ -767,11 +769,11 @@ function selectCurrentPersona() { | ||
| 767 | 769 | setPersonaDescription(); |
| 768 | 770 | |
| 769 | 771 | // Update the locked persona if setting is enabled |
| 770 | - if (power_user.persona_auto_lock && personaName && user_avatar !== chat_metadata['persona']) { | |
| 772 | + if (shouldAutoLock) { | |
| 771 | 773 | chat_metadata['persona'] = user_avatar; |
| 772 | 774 | console.log(`Auto locked persona to ${user_avatar}`); |
| 773 | 775 | if (toastPersonaNameChange && power_user.persona_show_notifications) { |
| 774 | 776 | toastr.infosuccess(`Auto locked personaPersona ${personaName} selected and auto-locked to current chat`, t`Persona Auto LockSelected`); |
| 775 | 777 | } |
| 776 | 778 | saveMetadataDebounced(); |
| 777 | 779 | updatePersonaLockIcons(); |
| @@ -788,7 +790,7 @@ function selectCurrentPersona() { | ||
| 788 | 790 | + t`Current Persona: ${power_user.personas[user_avatar]}` |
| 789 | 791 | + (hasDifferentChatLock ? '<br />' + t`Chat persona: ${power_user.personas[chat_metadata['persona']]}` : '') |
| 790 | 792 | + (hasDifferentDefaultLock ? '<br />' + t`Default persona: ${power_user.personas[power_user.default_persona]}` : ''); |
| 791 | 793 | toastr.info(message, t`Temporary Persona`, { escapeHtml: false, timeOut: 10000, extendedTimeOut: 20000, preventDuplicates: true }); |
| 792 | 794 | } |
| 793 | 795 | } |
| 794 | 796 | } |
| @@ -865,7 +867,7 @@ async function unlockPersona(type = 'chat') { | ||
| 865 | 867 | delete chat_metadata['persona']; |
| 866 | 868 | await saveMetadata(); |
| 867 | 869 | if (power_user.persona_show_notifications) { |
| 868 | 870 | toastr.info(t`User personaPersona ${name1} is now unlocked from this chat. Click the "Lock" again to revert.`, t`Persona unlockedUnlocked`); |
| 869 | 871 | } |
| 870 | 872 | } |
| 871 | 873 | break; |
| @@ -879,7 +881,7 @@ async function unlockPersona(type = 'chat') { | ||
| 879 | 881 | saveSettingsDebounced(); |
| 880 | 882 | updatePersonaConnectionsAvatarList(); |
| 881 | 883 | if (power_user.persona_show_notifications) { |
| 882 | 884 | toastr.info(t`User personaPersona ${name1} is now unlocked from character ${name2}. Click the "Lock" again to revert.`, t`Persona unlockedUnlocked`); |
| 883 | 885 | } |
| 884 | 886 | } |
| 885 | 887 | break; |
| @@ -900,11 +902,7 @@ async function lockPersona(type = 'chat') { | ||
| 900 | 902 | if (!(user_avatar in power_user.personas)) { |
| 901 | 903 | console.log(`Creating a new persona ${user_avatar}`); |
| 902 | 904 | if (power_user.persona_show_notifications) { |
| 903 | - toastr.info( | |
| 905 | + toastr.info(t`Creating a new persona for currently selected user name and avatar...`, t`Persona Not Found`); | |
| 904 | - t`Creating a new persona for currently selected user name and avatar...`, | |
| 905 | - t`Persona Does Not Exist`, | |
| 906 | - { timeOut: 10000, extendedTimeOut: 20000 }, | |
| 907 | - ); | |
| 908 | 906 | } |
| 909 | 907 | power_user.personas[user_avatar] = name1; |
| 910 | 908 | power_user.persona_descriptions[user_avatar] = { |
| @@ -1211,7 +1209,7 @@ async function toggleDefaultPersona(avatarId, { quiet: quiet = false } = {}) { | ||
| 1211 | 1209 | |
| 1212 | 1210 | power_user.default_persona = avatarId; |
| 1213 | 1211 | if (power_user.persona_show_notifications) { |
| 1214 | 1212 | toastr.success(t`Set to ${power_user.personas[avatarId]}.This persona will be used by default when you open a new chat.`, t`Default Persona Set`); |
| 1215 | 1213 | } |
| 1216 | 1214 | } |
| 1217 | 1215 | |
| @@ -1272,8 +1270,8 @@ async function loadPersonaForCurrentChat() { | ||
| 1272 | 1270 | if (connectedPersonas.length === 1) { |
| 1273 | 1271 | chatPersona = connectedPersonas[0]; |
| 1274 | 1272 | } else if (!power_user.persona_allow_multi_connections) { |
| 1273 | + console.warn('More than one persona is connected to this character.Using the first available persona for this chat.'); | |
| 1275 | 1274 | chatPersona = connectedPersonas[0]; |
| 1276 | - toastr.warning(t`More than one persona is connected to this character. Using the first available persona for this chat.`, t`Automatic Persona Selection`); | |
| 1277 | 1275 | } else { |
| 1278 | 1276 | chatPersona = await askForPersonaSelection(t`Select Persona`, |
| 1279 | 1277 | t`Multiple personas are connected to this character.\nSelect a persona to use for this chat.`, |
| @@ -1307,10 +1305,15 @@ async function loadPersonaForCurrentChat() { | ||
| 1307 | 1305 | |
| 1308 | 1306 | // Persona avatar found, select it |
| 1309 | 1307 | if (chatPersona) { |
| 1310 | - setUserAvatar(chatPersona); | |
| 1308 | + const willAutoLock = power_user.persona_auto_lock && user_avatar !== chat_metadata['persona']; | |
| 1309 | + setUserAvatar(chatPersona, { toastPersonaNameChange: false }); | |
| 1311 | 1310 | |
| 1312 | 1311 | if (power_user.persona_show_notifications) { |
| 1313 | - toastr.info(t`Auto-selected persona ${power_user.personas[chatPersona]} based on ${connectType} connection.`, t`Persona Auto Selected`); | |
| 1312 | + let message = t`Auto-selected persona based on ${connectType} connection.<br />Your messages will now be sent as ${power_user.personas[chatPersona]}.`; | |
| 1313 | + if (willAutoLock) { | |
| 1314 | + message += '<br /><br />' + t`Auto-locked this persona to current chat.`; | |
| 1315 | + } | |
| 1316 | + toastr.success(message, t`Persona Auto Selected`, { escapeHtml: false }); | |
| 1314 | 1317 | } |
| 1315 | 1318 | } |
| 1316 | 1319 | |