fix: handle localStorage being undefined
This commit is contained in:
parent
842383a5db
commit
0ab6cf0ff0
|
@ -120,11 +120,17 @@ export function savePortals() {
|
||||||
url: item.portalUrl,
|
url: item.portalUrl,
|
||||||
} as Portal;
|
} as Portal;
|
||||||
});
|
});
|
||||||
window.localStorage.setItem("portals", JSON.stringify(portals));
|
if (typeof globalThis.localStorage !== "undefined") {
|
||||||
|
globalThis.localStorage.setItem("portals", JSON.stringify(portals));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function loadSavedPortals(): Portal[] | null {
|
export function loadSavedPortals(): Portal[] | null {
|
||||||
let portals = window.localStorage.getItem("portals");
|
let portals: string | null = null;
|
||||||
|
|
||||||
|
if (typeof globalThis.localStorage !== "undefined") {
|
||||||
|
portals = globalThis.localStorage.getItem("portals");
|
||||||
|
}
|
||||||
|
|
||||||
if (!portals) {
|
if (!portals) {
|
||||||
return null;
|
return null;
|
||||||
|
|
Loading…
Reference in New Issue