On char rename, update auxiliary connections

- Move WI char lore (additional lorebooks) based on rename
- Move character-bound Author's Note based on rename
- Extend core `getCharFilename` to be able to take an avatarKey, instead of just uid
This commit is contained in:
Wolfsblvt
2025-02-17 05:32:13 +01:00
parent a771dd5478
commit 4f0921856f
2 changed files with 32 additions and 6 deletions

View File

@ -994,13 +994,18 @@ export function getImageSizeFromDataURL(dataUrl) {
});
}
export function getCharaFilename(chid) {
/**
* Gets the filename of the character avatar without extension
* @param {number?} [chid=null] - Character ID. If not provided, uses the current character ID
* @param {object} [options={}] - Options arguments
* @param {string?} [options.manualAvatarKey=null] - Manually take the following avatar key, instead of using the chid to determine the name
* @returns {string?} The filename of the character avatar without extension, or null if the character ID is invalid
*/
export function getCharaFilename(chid = null, { manualAvatarKey = null } = {}) {
const context = getContext();
const fileName = context.characters[chid ?? context.characterId]?.avatar;
const fileName = manualAvatarKey ?? context.characters[chid ?? context.characterId]?.avatar;
if (fileName) {
return fileName.replace(/\.[^/.]+$/, '');
}
return fileName?.replace(/\.[^/.]+$/, '') ?? null;
}
/**