From 0c88920f9ee2f09922e66f1c87a54cb97e6a7df0 Mon Sep 17 00:00:00 2001 From: Romein van Buren Date: Wed, 13 Jul 2022 12:10:20 +0200 Subject: [PATCH] Local storage fallback --- gui/dashboard/lib.js | 12 +++++++++++- lib/dashboard/build.js | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/gui/dashboard/lib.js b/gui/dashboard/lib.js index 217a46e..26167ba 100644 --- a/gui/dashboard/lib.js +++ b/gui/dashboard/lib.js @@ -19,7 +19,17 @@ function createSettingsStore() { s.set(val); } - updateStorage(JSON.parse(window.localStorage.getItem('statusdash'))); + const localStorageString = window.localStorage.getItem('statusdash'); + let localStorage = {}; + + try { + localStorage = JSON.parse(localStorageString); + } + catch { + localStorage = {}; + } + + updateStorage(localStorage); return { subscribe: s.subscribe, diff --git a/lib/dashboard/build.js b/lib/dashboard/build.js index d5cf555..cf4a4e5 100644 --- a/lib/dashboard/build.js +++ b/lib/dashboard/build.js @@ -40,7 +40,7 @@ async function build() { }); const { output } = await bundle.generate({ - sourcemap: false, + sourcemap: true, format: 'iife', name: 'app', file: 'public/build/bundle.js',