From ef3a9a810e632674680cf7d88d5bd04fcf6eac2e Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Tue, 8 Aug 2023 22:08:41 +0300 Subject: [PATCH] Fix avatar preview after changing it --- public/script.js | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/public/script.js b/public/script.js index 1441f6ebe..b2a57fd24 100644 --- a/public/script.js +++ b/public/script.js @@ -304,7 +304,6 @@ export const comment_avatar = "img/quill.png"; export let CLIENT_VERSION = 'SillyTavern:UNKNOWN:Cohee#1207'; // For Horde header let is_colab = false; let is_checked_colab = false; -let is_mes_reload_avatar = false; let optionsPopper = Popper.createPopper(document.getElementById('options_button'), document.getElementById('options'), { placement: 'top-start' }); @@ -1440,9 +1439,6 @@ function addOneMessage(mes, { type = "normal", insertAfter = null, scroll = true } else { if (characters[this_chid].avatar != "none") { avatarImg = getThumbnailUrl('avatar', characters[this_chid].avatar); - if (is_mes_reload_avatar !== false) { - avatarImg += "&" + is_mes_reload_avatar; - } } else { avatarImg = default_avatar; } @@ -4268,9 +4264,18 @@ async function read_avatar_load(input) { return; } - $("#create_button").trigger('click'); + await createOrEditCharacter(); + await delay(durationSaveEdit); const formData = new FormData($("#form_create").get(0)); + await fetch(getThumbnailUrl('avatar', formData.get('avatar_url')), { + method: 'GET', + cache: 'no-cache', + headers: { + 'pragma': 'no-cache', + 'cache-control': 'no-cache', + } + }); $(".mes").each(async function () { if ($(this).attr("is_system") == 'true') { @@ -4288,17 +4293,7 @@ async function read_avatar_load(input) { } }); - await delay(durationSaveEdit); - await fetch(getThumbnailUrl('avatar', formData.get('avatar_url')), { - method: 'GET', - cache: 'no-cache', - headers: { - 'pragma': 'no-cache', - 'cache-control': 'no-cache', - } - }); console.log('Avatar refreshed'); - } } @@ -7574,7 +7569,6 @@ $(document).ready(function () { }); $("#add_avatar_button").change(function () { - is_mes_reload_avatar = Date.now(); read_avatar_load(this); });