Navigate to current persona on switching chats

0274d800f992323fa8a7084117d41855ffb49a0f

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

1 files changed, +15 -5Ignore whitespace
public/scripts/personas.js+15 -5
@@ -68,6 +68,8 @@ export let user_avatar = '';
6868/** @type {FilterHelper} Filter helper for the persona list */
6969export const personasFilter = new FilterHelper(debounce(getUserAvatars, debounce_timeout.quick));
7070
71+/** @type {function(string): void} */
72+let navigateToAvatar = () => { };
7173
7274/**
7375 * Checks if the Persona Management panel is currently open
@@ -276,14 +278,16 @@ export async function getUserAvatars(doRender = true, openPageAt = '') {
276278 },
277279 });
278280
279281 ifnavigateToAvatar = (openPageAtavatarId) => {
280282 const avatarIndex = entities.indexOf(openPageAtavatarId);
281283 const page = Math.floor(avatarIndex / perPage) + 1;
282284
283285 if (avatarIndex !== -1) {
284286 $('#persona_pagination_container').pagination('go', page);
285287 }
286288 };
289+
290+ openPageAt && navigateToAvatar(openPageAt);
287291
288292 return allEntities;
289293 }
@@ -1255,9 +1259,15 @@ function getPersonaStates(avatarId) {
12551259 * and character lock, as well as updating icons and labels in the persona management panel to reflect
12561260 * the current state of the user's persona.
12571261 * Additionally, it manages the display of temporary persona lock information.
1262+ * @param {Object} [options={}] - Optional settings
1263+ * @param {boolean} [options.navigateToCurrent=false] - Whether to navigate to the current persona in the persona list
12581264 */
12591265
12601266function updatePersonaUIStates({ navigateToCurrent = false } = {}) {
1267+ if (navigateToCurrent) {
1268+ navigateToAvatar(user_avatar);
1269+ }
1270+
12611271 // Update the persona list
12621272 $('#user_avatar_block .avatar-container').each(function () {
12631273 const avatarId = $(this).attr('data-avatar-id');
@@ -1450,7 +1460,7 @@ async function loadPersonaForCurrentChat({ doRender = false } = {}) {
14501460 }
14511461 }
14521462
14531463 updatePersonaUIStates({ navigateToCurrent: true });
14541464
14551465 return !!chatPersona;
14561466}