2020-11-03 00:41:28 +01:00
|
|
|
export function loadLocalStorageData(itemKey) {
|
2018-10-24 08:31:45 +02:00
|
|
|
try {
|
2020-04-15 19:23:27 +02:00
|
|
|
const serializedData = window.localStorage.getItem(itemKey)
|
2018-10-24 08:31:45 +02:00
|
|
|
if (serializedData === null) {
|
|
|
|
return undefined
|
|
|
|
}
|
|
|
|
return JSON.parse(serializedData)
|
|
|
|
} catch (err) {
|
|
|
|
return undefined
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export function saveLocalStorageData(data, itemKey) {
|
2018-10-24 08:31:45 +02:00
|
|
|
try {
|
|
|
|
const serializedData = JSON.stringify(data)
|
2020-04-15 19:23:27 +02:00
|
|
|
window.localStorage.setItem(itemKey, serializedData)
|
2018-10-24 08:31:45 +02:00
|
|
|
} catch (err) {
|
|
|
|
console.warn(err)
|
|
|
|
}
|
|
|
|
}
|