From f16a4f1a4e555caf24cd2aaa31a1a316eb331335 Mon Sep 17 00:00:00 2001 From: Snarling <84951833+Snarling@users.noreply.github.com> Date: Mon, 13 Feb 2023 19:49:07 -0500 Subject: [PATCH] fix setTheme --- src/NetscriptFunctions/UserInterface.ts | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/NetscriptFunctions/UserInterface.ts b/src/NetscriptFunctions/UserInterface.ts index 1fa7e635f..3db2c84c6 100644 --- a/src/NetscriptFunctions/UserInterface.ts +++ b/src/NetscriptFunctions/UserInterface.ts @@ -28,17 +28,16 @@ export function NetscriptUserInterface(): InternalAPI { const hex = /^(#)((?:[A-Fa-f0-9]{2}){3,4}|(?:[A-Fa-f0-9]{3}))$/; const currentTheme = { ...Settings.theme }; const errors: string[] = []; - if (typeof newTheme !== "object") - for (const key of Object.keys(newTheme)) { - if (!currentTheme[key]) { - // Invalid key - errors.push(`Invalid key "${key}"`); - } else if (!hex.test(newTheme[key] ?? "")) { - errors.push(`Invalid color "${key}": ${newTheme[key]}`); - } else { - currentTheme[key] = newTheme[key]; - } + for (const key of Object.keys(newTheme)) { + if (!currentTheme[key]) { + // Invalid key + errors.push(`Invalid key "${key}"`); + } else if (!hex.test(newTheme[key] ?? "")) { + errors.push(`Invalid color "${key}": ${newTheme[key]}`); + } else { + currentTheme[key] = newTheme[key]; } + } if (errors.length === 0) { Object.assign(Settings.theme, currentTheme);