Only navigate to persona if switched by connection
| @@ -26,7 +26,7 @@ import { PAGINATION_TEMPLATE, clearInfoBlock, debounce, delay, download, ensureI | ||
| 26 | 26 | import { debounce_timeout } from './constants.js'; |
| 27 | 27 | import { FILTER_TYPES, FilterHelper } from './filters.js'; |
| 28 | 28 | import { groups, selected_group } from './group-chats.js'; |
| 29 | 29 | import { POPUP_RESULT, POPUP_TYPE, Popup, callGenericPopup } from './popup.js'; |
| 30 | 30 | import { t } from './i18n.js'; |
| 31 | 31 | import { openWorldInfoEditor, world_names } from './world-info.js'; |
| 32 | 32 | import { renderTemplateAsync } from './templates.js'; |
| @@ -102,11 +102,14 @@ export function initUserAvatar(avatar) { | ||
| 102 | 102 | /** |
| 103 | 103 | * Sets a user avatar file |
| 104 | 104 | * @param {string} imgfile Link to an image file |
| 105 | + * @param {object} [options] Optional settings | |
| 106 | + * @param {boolean} [options.toastPersonaNameChange=true] Whether to show a toast when the persona name is changed | |
| 107 | + * @param {boolean} [options.navigateToCurrent=false] Whether to navigate to the current persona after setting the avatar | |
| 105 | 108 | */ |
| 106 | 109 | export function setUserAvatar(imgfile, { toastPersonaNameChange = true, navigateToCurrent = false } = {}) { |
| 107 | 110 | user_avatar = imgfile && typeof imgfile === 'string' ? imgfile : $(this).attr('data-avatar-id'); |
| 108 | 111 | reloadUserAvatar(); |
| 109 | 112 | updatePersonaUIStates({ navigateToCurrent: navigateToCurrent }); |
| 110 | 113 | selectCurrentPersona({ toastPersonaNameChange: toastPersonaNameChange }); |
| 111 | 114 | saveSettingsDebounced(); |
| 112 | 115 | $('.zoomed_avatar[forchar]').remove(); |
| @@ -1451,7 +1454,7 @@ async function loadPersonaForCurrentChat({ doRender = false } = {}) { | ||
| 1451 | 1454 | // Persona avatar found, select it |
| 1452 | 1455 | if (chatPersona && user_avatar !== chatPersona) { |
| 1453 | 1456 | const willAutoLock = power_user.persona_auto_lock && user_avatar !== chat_metadata['persona']; |
| 1454 | 1457 | setUserAvatar(chatPersona, { toastPersonaNameChange: false, navigateToCurrent: true }); |
| 1455 | 1458 | |
| 1456 | 1459 | if (power_user.persona_show_notifications) { |
| 1457 | 1460 | let message = t`Auto-selected persona based on ${connectType} connection.<br />Your messages will now be sent as ${power_user.personas[chatPersona]}.`; |
| @@ -1462,7 +1465,7 @@ async function loadPersonaForCurrentChat({ doRender = false } = {}) { | ||
| 1462 | 1465 | } |
| 1463 | 1466 | } |
| 1464 | 1467 | |
| 1465 | 1468 | updatePersonaUIStates({ navigateToCurrent: true }); |
| 1466 | 1469 | |
| 1467 | 1470 | return !!chatPersona; |
| 1468 | 1471 | } |