From f5a8622e79ed311e588935841b2b4a5ff8d7efea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20V=C3=A1clav=C3=ADk?= Date: Sun, 7 Apr 2024 12:50:00 +0200 Subject: [PATCH] climbing: Fix undefined window --- src/components/FeaturePanel/Climbing/utils/ascents.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/components/FeaturePanel/Climbing/utils/ascents.ts b/src/components/FeaturePanel/Climbing/utils/ascents.ts index 382c9afef..b47046414 100644 --- a/src/components/FeaturePanel/Climbing/utils/ascents.ts +++ b/src/components/FeaturePanel/Climbing/utils/ascents.ts @@ -4,6 +4,7 @@ const KEY = 'ascents'; // @TODO generic util? export const getLocalStorageItem = (key: string) => { + if (typeof window === 'undefined') return []; const raw = window?.localStorage.getItem(key); if (raw) { try { @@ -19,6 +20,7 @@ export const getLocalStorageItem = (key: string) => { // @TODO generic util? export const setLocalStorageItem = (key: string, value: JSONValue) => { + if (typeof window === 'undefined') return; window?.localStorage.setItem(key, JSON.stringify(value)); };