From 3ed7ccbc5708476b8b4095553828d16914e2eda8 Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Sat, 16 Mar 2024 18:22:33 +0200 Subject: [PATCH] Fix double rendering of first message when opening a chat with only 1 message --- public/script.js | 10 +++++++++- public/scripts/personas.js | 7 ------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/public/script.js b/public/script.js index ca85afbc7..bcda7534d 100644 --- a/public/script.js +++ b/public/script.js @@ -8328,7 +8328,15 @@ jQuery(async function () { } }); - $(document).on('click', '#user_avatar_block .avatar-container', setUserAvatar); + $(document).on('click', '#user_avatar_block .avatar-container', function () { + const imgfile = $(this).attr('imgfile'); + setUserAvatar(imgfile); + + // force firstMes {{user}} update on persona switch + if (this_chid >= 0 && !selected_group && chat.length === 1) { + $('#firstmessage_textarea').trigger('input'); + } + }); $(document).on('click', '#user_avatar_block .avatar_upload', function () { $('#avatar_upload_overwrite').val(''); $('#avatar_upload_file').trigger('click'); diff --git a/public/scripts/personas.js b/public/scripts/personas.js index b54ee7fd5..e0fee6592 100644 --- a/public/scripts/personas.js +++ b/public/scripts/personas.js @@ -16,7 +16,6 @@ import { this_chid, user_avatar, } from '../script.js'; -import { getContext } from './extensions.js'; import { persona_description_positions, power_user } from './power-user.js'; import { getTokenCount } from './tokenizers.js'; import { debounce, delay, download, parseJsonFile } from './utils.js'; @@ -296,12 +295,6 @@ export function selectCurrentPersona() { } setPersonaDescription(); - - // force firstMes {{user}} update on persona switch - const context = getContext(); - if (context.characterId >= 0 && !context.groupId && context.chat.length === 1) { - $('#firstmessage_textarea').trigger('input'); - } } }