mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Force new user avatar when syncing personas.
This commit is contained in:
@ -1147,7 +1147,7 @@ function addOneMessage(mes, { type = "normal", insertAfter = null, scroll = true
|
|||||||
var characterName = name1; //set to user's name by default
|
var characterName = name1; //set to user's name by default
|
||||||
} else { var characterName = mes.name }
|
} else { var characterName = mes.name }
|
||||||
|
|
||||||
var avatarImg = "User Avatars/" + user_avatar;
|
var avatarImg = getUserAvatar(user_avatar);
|
||||||
const isSystem = mes.is_system;
|
const isSystem = mes.is_system;
|
||||||
const title = mes.title;
|
const title = mes.title;
|
||||||
generatedPromtCache = "";
|
generatedPromtCache = "";
|
||||||
@ -1303,6 +1303,10 @@ function addOneMessage(mes, { type = "normal", insertAfter = null, scroll = true
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getUserAvatar(avatarImg) {
|
||||||
|
return `User Avatars/${avatarImg}`;
|
||||||
|
}
|
||||||
|
|
||||||
function formatGenerationTimer(gen_started, gen_finished) {
|
function formatGenerationTimer(gen_started, gen_finished) {
|
||||||
if (!gen_started || !gen_finished) {
|
if (!gen_started || !gen_finished) {
|
||||||
return {};
|
return {};
|
||||||
@ -2625,7 +2629,7 @@ export async function sendMessageAsUser(textareaText, messageBias) {
|
|||||||
|
|
||||||
// Lock user avatar to a persona.
|
// Lock user avatar to a persona.
|
||||||
if (user_avatar in power_user.personas) {
|
if (user_avatar in power_user.personas) {
|
||||||
chat[chat.length - 1]['force_avatar'] = `User Avatars/${user_avatar}`;
|
chat[chat.length - 1]['force_avatar'] = getUserAvatar(user_avatar);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (messageBias) {
|
if (messageBias) {
|
||||||
@ -3906,7 +3910,7 @@ function appendUserAvatar(name) {
|
|||||||
}
|
}
|
||||||
template.find('.avatar').attr('imgfile', name);
|
template.find('.avatar').attr('imgfile', name);
|
||||||
template.toggleClass('default_persona', name === power_user.default_persona)
|
template.toggleClass('default_persona', name === power_user.default_persona)
|
||||||
template.find('img').attr('src', `User Avatars/${name}`);
|
template.find('img').attr('src', getUserAvatar(name));
|
||||||
$("#user_avatar_block").append(template);
|
$("#user_avatar_block").append(template);
|
||||||
highlightSelectedAvatar();
|
highlightSelectedAvatar();
|
||||||
}
|
}
|
||||||
@ -3916,7 +3920,7 @@ function reloadUserAvatar() {
|
|||||||
if ($(this).attr("is_user") == 'true' && $(this).attr('force_avatar') == 'false') {
|
if ($(this).attr("is_user") == 'true' && $(this).attr('force_avatar') == 'false') {
|
||||||
$(this)
|
$(this)
|
||||||
.find(".avatar img")
|
.find(".avatar img")
|
||||||
.attr("src", `User Avatars/${user_avatar}`);
|
.attr("src", getUserAvatar(user_avatar));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -7024,6 +7028,7 @@ $(document).ready(function () {
|
|||||||
for (const mes of chat) {
|
for (const mes of chat) {
|
||||||
if (mes.is_user) {
|
if (mes.is_user) {
|
||||||
mes.name = name1;
|
mes.name = name1;
|
||||||
|
mes.force_avatar = getUserAvatar(user_avatar);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user