mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
World Info: Fix array splice method
Character lore layers used array.splice() in the wrong way. Somehow this passed my testing through sheer luck. Rewrite for using indicies to splice and for more efficiency with iteration. Signed-off-by: kingbri <bdashore3@proton.me>
This commit is contained in:
@ -250,16 +250,18 @@ function displayWorldEntries(name, data) {
|
||||
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;
|
||||
if (world_info.charLore) {
|
||||
world_info.charLore.forEach((charLore, index) => {
|
||||
if (charLore.extraBooks?.includes(name)) {
|
||||
const tempCharLore = charLore.extraBooks.filter((e) => e !== name);
|
||||
if (tempCharLore.length === 0) {
|
||||
world_info.charLore.splice(index, 1);
|
||||
} else {
|
||||
charLore.extraBooks = tempCharLore;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
saveSettingsDebounced();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user