mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
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:
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user