Only navigate to persona if switched by connection

90be2eee717e18a4e2a88b28954a51853db8d457

Cohee <18619528+Cohee1207@users.noreply.github.com>

1 files changed, +8 -5Ignore whitespace
public/scripts/personas.js+8 -5
@@ -26,7 +26,7 @@ import { PAGINATION_TEMPLATE, clearInfoBlock, debounce, delay, download, ensureI
2626import { debounce_timeout } from './constants.js';
2727import { FILTER_TYPES, FilterHelper } from './filters.js';
2828import { groups, selected_group } from './group-chats.js';
2929import { POPUP_RESULT, POPUP_TYPE, Popup, callGenericPopup } from './popup.js';
3030import { t } from './i18n.js';
3131import { openWorldInfoEditor, world_names } from './world-info.js';
3232import { renderTemplateAsync } from './templates.js';
@@ -102,11 +102,14 @@ export function initUserAvatar(avatar) {
102102/**
103103 * Sets a user avatar file
104104 * @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
105108 */
106109export function setUserAvatar(imgfile, { toastPersonaNameChange = true, navigateToCurrent = false } = {}) {
107110 user_avatar = imgfile && typeof imgfile === 'string' ? imgfile : $(this).attr('data-avatar-id');
108111 reloadUserAvatar();
109112 updatePersonaUIStates({ navigateToCurrent: navigateToCurrent });
110113 selectCurrentPersona({ toastPersonaNameChange: toastPersonaNameChange });
111114 saveSettingsDebounced();
112115 $('.zoomed_avatar[forchar]').remove();
@@ -1451,7 +1454,7 @@ async function loadPersonaForCurrentChat({ doRender = false } = {}) {
14511454 // Persona avatar found, select it
14521455 if (chatPersona && user_avatar !== chatPersona) {
14531456 const willAutoLock = power_user.persona_auto_lock && user_avatar !== chat_metadata['persona'];
14541457 setUserAvatar(chatPersona, { toastPersonaNameChange: false, navigateToCurrent: true });
14551458
14561459 if (power_user.persona_show_notifications) {
14571460 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 } = {}) {
14621465 }
14631466 }
14641467
14651468 updatePersonaUIStates({ navigateToCurrent: true });
14661469
14671470 return !!chatPersona;
14681471}