From a6a97aa9c7d4465a9caa0402c992d081ed2d42d8 Mon Sep 17 00:00:00 2001 From: Ben Busby Date: Wed, 3 Aug 2022 17:59:08 -0600 Subject: [PATCH] Catch failure to restore adv search state Shouldn't throw any errors if this fails to be restored from local storage for any reason. It's purely a nice-to-have feature. --- app/static/js/header.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/static/js/header.js b/app/static/js/header.js index e50586b..e3c8d2c 100644 --- a/app/static/js/header.js +++ b/app/static/js/header.js @@ -25,7 +25,12 @@ document.addEventListener("DOMContentLoaded", () => { localStorage.advSearchToggled = on; } - toggleAdvancedSearch(JSON.parse(localStorage.advSearchToggled)); + try { + toggleAdvancedSearch(JSON.parse(localStorage.advSearchToggled)); + } catch (error) { + console.warn("Did not recover advanced search toggle state"); + } + advSearchToggle.onclick = () => { toggleAdvancedSearch(advSearchToggle.checked); }