From 3e30fb5d14e2e4f92f85ed2471dc4c1aebbc5764 Mon Sep 17 00:00:00 2001 From: kingbri Date: Mon, 26 Jun 2023 20:19:21 -0400 Subject: [PATCH] World Info: Fix lorebook loading error charLore isn't always present, so make optional calls to it. Signed-off-by: kingbri --- public/scripts/world-info.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/public/scripts/world-info.js b/public/scripts/world-info.js index 7b7bdc710..8942040df 100644 --- a/public/scripts/world-info.js +++ b/public/scripts/world-info.js @@ -250,7 +250,7 @@ function displayWorldEntries(name, data) { return; } - const existingCharLores = world_info.charLore.filter((e) => e.extraBooks.includes(name)); + 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); @@ -627,7 +627,7 @@ async function renameWorldInfo(name, data) { await saveWorldInfo(newName, data, true); await deleteWorldInfo(oldName); - const existingCharLores = world_info.charLore.filter((e) => e.extraBooks.includes(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); @@ -747,7 +747,7 @@ async function getCharacterLore() { // TODO: Maybe make the utility function not use the window context? const fileName = getCharaFilename(this_chid); - const extraCharLore = world_info.charLore.find((e) => e.name === fileName); + const extraCharLore = world_info.charLore?.find((e) => e.name === fileName); if (extraCharLore) { worldsToSearch = new Set([...worldsToSearch, ...extraCharLore.extraBooks]); }