mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Merge pull request #586 from bdashore3/dev
[IMPORTANT] Fix world info splice method
This commit is contained in:
@ -5544,21 +5544,20 @@ function openCharacterWorldPopup() {
|
|||||||
const fileName = getCharaFilename(chid);
|
const fileName = getCharaFilename(chid);
|
||||||
const tempExtraBooks = selectedWorlds.map((index) => world_names[index]).filter((e) => e !== undefined);
|
const tempExtraBooks = selectedWorlds.map((index) => world_names[index]).filter((e) => e !== undefined);
|
||||||
|
|
||||||
const existingCharLore = charLore.find((e) => e.name === fileName);
|
const existingCharIndex = charLore.findIndex((e) => e.name === fileName);
|
||||||
if (existingCharLore) {
|
if (existingCharIndex === -1) {
|
||||||
if (tempExtraBooks.length === 0) {
|
|
||||||
charLore.splice(existingCharLore, 1);
|
|
||||||
} else {
|
|
||||||
existingCharLore.extraBooks = tempExtraBooks;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
const newCharLoreEntry = {
|
const newCharLoreEntry = {
|
||||||
name: fileName,
|
name: fileName,
|
||||||
extraBooks: tempExtraBooks
|
extraBooks: tempExtraBooks
|
||||||
}
|
}
|
||||||
|
|
||||||
charLore.push(newCharLoreEntry);
|
charLore.push(newCharLoreEntry);
|
||||||
|
} else if (tempExtraBooks.length === 0) {
|
||||||
|
charLore.splice(existingCharIndex, 1);
|
||||||
|
} else {
|
||||||
|
charLore[existingCharIndex].extraBooks = tempExtraBooks;
|
||||||
}
|
}
|
||||||
|
|
||||||
Object.assign(world_info, { charLore: charLore });
|
Object.assign(world_info, { charLore: charLore });
|
||||||
saveSettingsDebounced();
|
saveSettingsDebounced();
|
||||||
}
|
}
|
||||||
|
@ -250,16 +250,18 @@ function displayWorldEntries(name, data) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const existingCharLores = world_info.charLore?.filter((e) => e.extraBooks.includes(name));
|
if (world_info.charLore) {
|
||||||
if (existingCharLores && existingCharLores.length > 0) {
|
world_info.charLore.forEach((charLore, index) => {
|
||||||
existingCharLores.forEach((charLore) => {
|
if (charLore.extraBooks?.includes(name)) {
|
||||||
const tempCharLore = charLore.extraBooks.filter((e) => e !== name);
|
const tempCharLore = charLore.extraBooks.filter((e) => e !== name);
|
||||||
if (tempCharLore.length === 0) {
|
if (tempCharLore.length === 0) {
|
||||||
world_info.charLore.splice(charLore, 1);
|
world_info.charLore.splice(index, 1);
|
||||||
} else {
|
} else {
|
||||||
charLore.extraBooks = tempCharLore;
|
charLore.extraBooks = tempCharLore;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
saveSettingsDebounced();
|
saveSettingsDebounced();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user