Navigate to current persona on switching chats
| @@ -68,6 +68,8 @@ export let user_avatar = ''; | ||
| 68 | 68 | /** @type {FilterHelper} Filter helper for the persona list */ |
| 69 | 69 | export const personasFilter = new FilterHelper(debounce(getUserAvatars, debounce_timeout.quick)); |
| 70 | 70 | |
| 71 | +/** @type {function(string): void} */ | |
| 72 | +let navigateToAvatar = () => { }; | |
| 71 | 73 | |
| 72 | 74 | /** |
| 73 | 75 | * Checks if the Persona Management panel is currently open |
| @@ -276,14 +278,16 @@ export async function getUserAvatars(doRender = true, openPageAt = '') { | ||
| 276 | 278 | }, |
| 277 | 279 | }); |
| 278 | 280 | |
| 279 | 281 | ifnavigateToAvatar = (openPageAtavatarId) => { |
| 280 | 282 | const avatarIndex = entities.indexOf(openPageAtavatarId); |
| 281 | 283 | const page = Math.floor(avatarIndex / perPage) + 1; |
| 282 | 284 | |
| 283 | 285 | if (avatarIndex !== -1) { |
| 284 | 286 | $('#persona_pagination_container').pagination('go', page); |
| 285 | 287 | } |
| 286 | 288 | }; |
| 289 | + | |
| 290 | + openPageAt && navigateToAvatar(openPageAt); | |
| 287 | 291 | |
| 288 | 292 | return allEntities; |
| 289 | 293 | } |
| @@ -1255,9 +1259,15 @@ function getPersonaStates(avatarId) { | ||
| 1255 | 1259 | * and character lock, as well as updating icons and labels in the persona management panel to reflect |
| 1256 | 1260 | * the current state of the user's persona. |
| 1257 | 1261 | * 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 | |
| 1258 | 1264 | */ |
| 1259 | 1265 | |
| 1260 | 1266 | function updatePersonaUIStates({ navigateToCurrent = false } = {}) { |
| 1267 | + if (navigateToCurrent) { | |
| 1268 | + navigateToAvatar(user_avatar); | |
| 1269 | + } | |
| 1270 | + | |
| 1261 | 1271 | // Update the persona list |
| 1262 | 1272 | $('#user_avatar_block .avatar-container').each(function () { |
| 1263 | 1273 | const avatarId = $(this).attr('data-avatar-id'); |
| @@ -1450,7 +1460,7 @@ async function loadPersonaForCurrentChat({ doRender = false } = {}) { | ||
| 1450 | 1460 | } |
| 1451 | 1461 | } |
| 1452 | 1462 | |
| 1453 | 1463 | updatePersonaUIStates({ navigateToCurrent: true }); |
| 1454 | 1464 | |
| 1455 | 1465 | return !!chatPersona; |
| 1456 | 1466 | } |