From a113d188fa285ad41ff3eac2929eee6f8cb9fb19 Mon Sep 17 00:00:00 2001 From: buzz-lightsnack-2007 <73412182+buzz-lightsnack-2007@users.noreply.github.com> Date: Wed, 8 May 2024 23:54:05 +0800 Subject: [PATCH] handle undefined data when reading --- scripts/secretariat.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/secretariat.js b/scripts/secretariat.js index 12e678a..e95e07d 100644 --- a/scripts/secretariat.js +++ b/scripts/secretariat.js @@ -44,7 +44,7 @@ class global { DATA[`local`] = await global.read((NAME) ? [...NAME] : null, -1); // Now return the data. - DATA_RETURNED[`source`] = (DATA[`sync`] != null) ? `sync` : `local`; + DATA_RETURNED[`source`] = (DATA[`sync`] != null && !(typeof DATA[`sync`]).includes(`undef`)) ? `sync` : `local`; DATA_RETURNED[`value`] = DATA[DATA_RETURNED[`source`]]; // Override the data with managed data if available. @@ -194,7 +194,7 @@ class global { : ((path != null) ? path : []) // Ensure that path isn't empty. // Merge! - DATA_INJECTED = nested.dictionary.set(DATA_ALL, (DATA_NAME != null) ? [...DATA_NAME] : DATA_NAME, data, (OPTIONS[`strict`] != null) ? OPTIONS[`strict`] : false); + DATA_INJECTED = nested.dictionary.set(DATA_ALL, (DATA_NAME != null) ? [...DATA_NAME] : DATA_NAME, data, OPTIONS); // If cloud is not selected, get where the data is already existent. (CLOUD == 0 || CLOUD == null)