mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
World Info: Add rename and delete hooks to char layers
If a world info is renamed or deleted, update that in the character lore section of settings as well. Signed-off-by: kingbri <bdashore3@proton.me>
This commit is contained in:
@ -250,6 +250,19 @@ function displayWorldEntries(name, data) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const existingCharLores = world_info.charLore.filter((e) => e.extraBooks.includes(name));
|
||||||
|
if (existingCharLores && existingCharLores.length > 0) {
|
||||||
|
existingCharLores.forEach((charLore) => {
|
||||||
|
const tempCharLore = charLore.extraBooks.filter((e) => e !== name);
|
||||||
|
if (tempCharLore.length === 0) {
|
||||||
|
world_info.charLore.splice(charLore, 1);
|
||||||
|
} else {
|
||||||
|
charLore.extraBooks = tempCharLore;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
saveSettingsDebounced();
|
||||||
|
}
|
||||||
|
|
||||||
// Selected world_info automatically refreshes
|
// Selected world_info automatically refreshes
|
||||||
await deleteWorldInfo(name);
|
await deleteWorldInfo(name);
|
||||||
});
|
});
|
||||||
@ -614,6 +627,16 @@ async function renameWorldInfo(name, data) {
|
|||||||
await saveWorldInfo(newName, data, true);
|
await saveWorldInfo(newName, data, true);
|
||||||
await deleteWorldInfo(oldName);
|
await deleteWorldInfo(oldName);
|
||||||
|
|
||||||
|
const existingCharLores = world_info.charLore.filter((e) => e.extraBooks.includes(oldName));
|
||||||
|
if (existingCharLores && existingCharLores.length > 0) {
|
||||||
|
existingCharLores.forEach((charLore) => {
|
||||||
|
const tempCharLore = charLore.extraBooks.filter((e) => e !== oldName);
|
||||||
|
tempCharLore.push(newName);
|
||||||
|
charLore.extraBooks = tempCharLore;
|
||||||
|
});
|
||||||
|
saveSettingsDebounced();
|
||||||
|
}
|
||||||
|
|
||||||
if (entryPreviouslySelected !== -1) {
|
if (entryPreviouslySelected !== -1) {
|
||||||
const wiElement = getWIElement(newName);
|
const wiElement = getWIElement(newName);
|
||||||
wiElement.prop("selected", true);
|
wiElement.prop("selected", true);
|
||||||
|
Reference in New Issue
Block a user