From ff318d464bcae798200c6548bfe7568c1b19587a Mon Sep 17 00:00:00 2001 From: buzz-lightsnack-2007 <73412182+buzz-lightsnack-2007@users.noreply.github.com> Date: Fri, 3 May 2024 23:47:53 +0800 Subject: [PATCH] use await to avoid unnecessary throwing error messages --- scripts/secretariat.js | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/scripts/secretariat.js b/scripts/secretariat.js index a52b464..30dbd64 100644 --- a/scripts/secretariat.js +++ b/scripts/secretariat.js @@ -428,19 +428,11 @@ class session { return DATABASE; } - /* Forcibly write the data to chrome database - - @param {object} DATA the data - */ - const store = async (DATA) => { - return(chrome.storage.session.set(DATA)); - } - async function verify (NAME, DATA) { let DATA_CHECK = {}; // Verify the presence of the data. - DATA_CHECK[`state`] = await compare(null, [session.read([...NAME]), DATA]); + DATA_CHECK[`state`] = await compare(null, [await session.read([...NAME]), DATA]); // Only notify when writing failed. (!DATA_CHECK[`state`]) @@ -462,8 +454,8 @@ class session { DATA[`inject`] = nest(DATA[`all`], [...TARGET], DATA[`write`]); // Write! - store(DATA[`inject`]); - return(verify(TARGET, DATA[`write`])); + chrome.storage.session.set(DATA[`inject`]); + return(await verify(TARGET, DATA[`write`])); } }