From 076e5e3186a61c277df2b349a588d6d7b03d31e9 Mon Sep 17 00:00:00 2001 From: Wolfsblvt Date: Sat, 25 Jan 2025 18:23:00 +0100 Subject: [PATCH] Fix temporary persona toast - Temporary persona toast was appearing when auto-lock was enabled, which didn't make sense --- public/scripts/personas.js | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/public/scripts/personas.js b/public/scripts/personas.js index 11b2bafe1..e54676863 100644 --- a/public/scripts/personas.js +++ b/public/scripts/personas.js @@ -684,18 +684,6 @@ async function bindUserNameToPersona(e) { function selectCurrentPersona() { const personaName = power_user.personas[user_avatar]; if (personaName) { - const hasDifferentChatLock = chat_metadata['persona'] && chat_metadata['persona'] !== user_avatar; - const hasDifferentDefaultLock = power_user.default_persona && power_user.default_persona !== user_avatar; - - if (hasDifferentChatLock || (!chat_metadata['persona'] && hasDifferentDefaultLock)) { - const message = t`A different persona is locked to this chat, or you have a different default persona set. The currently selected persona will only be temporary, and resets on reload. Consider locking this persona to the chat if you want to permanently use it.` - + '

' - + t`Current Persona: ${power_user.personas[user_avatar]}` - + (hasDifferentChatLock ? '
' + t`Chat persona: ${power_user.personas[chat_metadata['persona']]}` : '') - + (hasDifferentDefaultLock ? '
' + t`Default persona: ${power_user.personas[power_user.default_persona]}` : ''); - toastr.info(message, t`Temporary Persona`, { escapeHtml: false, timeOut: 10000, extendedTimeOut: 20000, preventDuplicates: true }); - } - if (personaName !== name1) { console.log(`Auto-updating user name to ${personaName}`); setUserName(personaName); @@ -736,6 +724,19 @@ function selectCurrentPersona() { } saveMetadataDebounced(); } + + // As the last step, inform user if the persona is only temporarily chosen + const hasDifferentChatLock = !!chat_metadata['persona'] && chat_metadata['persona'] !== user_avatar; + const hasDifferentDefaultLock = power_user.default_persona && power_user.default_persona !== user_avatar; + + if (hasDifferentChatLock || (!chat_metadata['persona'] && hasDifferentDefaultLock)) { + const message = t`A different persona is locked to this chat, or you have a different default persona set. The currently selected persona will only be temporary, and resets on reload. Consider locking this persona to the chat if you want to permanently use it.` + + '

' + + t`Current Persona: ${power_user.personas[user_avatar]}` + + (hasDifferentChatLock ? '
' + t`Chat persona: ${power_user.personas[chat_metadata['persona']]}` : '') + + (hasDifferentDefaultLock ? '
' + t`Default persona: ${power_user.personas[power_user.default_persona]}` : ''); + toastr.info(message, t`Temporary Persona`, { escapeHtml: false, timeOut: 10000, extendedTimeOut: 20000, preventDuplicates: true }); + } } }