mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Add missing personas on load
This commit is contained in:
@@ -190,6 +190,18 @@ function getUserAvatarBlock(avatarId) {
|
|||||||
return template;
|
return template;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize missing personas in the power user settings.
|
||||||
|
* @param {string[]} avatarsList List of avatar file names
|
||||||
|
*/
|
||||||
|
function addMissingPersonas(avatarsList) {
|
||||||
|
for (const persona of avatarsList) {
|
||||||
|
if (!power_user.personas[persona]) {
|
||||||
|
initPersona(persona, '[Unnamed Persona]', '');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a list of user avatars.
|
* Gets a list of user avatars.
|
||||||
* @param {boolean} doRender Whether to render the list
|
* @param {boolean} doRender Whether to render the list
|
||||||
@@ -212,6 +224,8 @@ export async function getUserAvatars(doRender = true, openPageAt = '') {
|
|||||||
return allEntities;
|
return allEntities;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If any persona is missing from the power user settings, we add it
|
||||||
|
addMissingPersonas(allEntities);
|
||||||
// Before printing the personas, we check if we should enable/disable search sorting
|
// Before printing the personas, we check if we should enable/disable search sorting
|
||||||
verifyPersonaSearchSortRule();
|
verifyPersonaSearchSortRule();
|
||||||
|
|
||||||
@@ -1586,11 +1600,9 @@ async function migrateNonPersonaUser() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
power_user.personas[user_avatar] = name1;
|
initPersona(user_avatar, name1, '');
|
||||||
void getOrCreatePersonaDescriptor();
|
|
||||||
setPersonaDescription();
|
setPersonaDescription();
|
||||||
await getUserAvatars(true, user_avatar);
|
await getUserAvatars(true, user_avatar);
|
||||||
saveSettingsDebounced();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function initPersonas() {
|
export async function initPersonas() {
|
||||||
|
Reference in New Issue
Block a user