diff options
author | Sebastian <sebasjm@gmail.com> | 2023-12-06 15:11:38 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2023-12-06 15:11:50 -0300 |
commit | dc02188d6bcae8446b27f0a094076fdd006931d1 (patch) | |
tree | e325d6b92ff578295eef6b8baac816e545dce517 /packages/demobank-ui | |
parent | 0acafda82911f3d61d4eaa9dec2263ae66863097 (diff) | |
download | wallet-core-dc02188d6bcae8446b27f0a094076fdd006931d1.tar.xz |
fix codec was setting values to undefined
Diffstat (limited to 'packages/demobank-ui')
-rw-r--r-- | packages/demobank-ui/src/Routing.tsx | 2 | ||||
-rw-r--r-- | packages/demobank-ui/src/settings.ts | 11 |
2 files changed, 11 insertions, 2 deletions
diff --git a/packages/demobank-ui/src/Routing.tsx b/packages/demobank-ui/src/Routing.tsx index 8ed66d4cf..aa46f2b7d 100644 --- a/packages/demobank-ui/src/Routing.tsx +++ b/packages/demobank-ui/src/Routing.tsx @@ -43,7 +43,7 @@ export function Routing(): VNode { const history = createHashHistory(); const backend = useBackendState(); const settings = useSettingsContext(); - const {config} = useBankCoreApiContext(); + const { config } = useBankCoreApiContext(); const { i18n } = useTranslationContext(); if (backend.state.status === "loggedOut") { diff --git a/packages/demobank-ui/src/settings.ts b/packages/demobank-ui/src/settings.ts index b7d285519..2c6ac1c67 100644 --- a/packages/demobank-ui/src/settings.ts +++ b/packages/demobank-ui/src/settings.ts @@ -64,13 +64,22 @@ const codecForBankUISettings = (): Codec<BankUiSettings> => .property("topNavSites", codecOptional(codecForMap(codecForString()))) .build("BankUiSettings"); +function removeUndefineField(obj: any): object { + return Object.keys(obj).reduce((prev, cur) => { + if (typeof prev[cur] === "undefined") { + delete prev[cur] + } + return prev + }, obj) +} + export function fetchSettings(listener: (s: BankUiSettings) => void): void { fetch("./settings.json") .then(resp => resp.json()) .then(json => codecForBankUISettings().decode(json)) .then(result => listener({ ...defaultSettings, - ...result, + ...removeUndefineField(result), })) .catch(e => { console.log("failed to fetch settings", e) |