aboutsummaryrefslogtreecommitdiffstats
path: root/ui/lib/local-storage-helpers.js
diff options
context:
space:
mode:
Diffstat (limited to 'ui/lib/local-storage-helpers.js')
-rw-r--r--ui/lib/local-storage-helpers.js20
1 files changed, 20 insertions, 0 deletions
diff --git a/ui/lib/local-storage-helpers.js b/ui/lib/local-storage-helpers.js
new file mode 100644
index 000000000..287586c49
--- /dev/null
+++ b/ui/lib/local-storage-helpers.js
@@ -0,0 +1,20 @@
+export function loadLocalStorageData (itemKey) {
+ try {
+ const serializedData = localStorage.getItem(itemKey)
+ if (serializedData === null) {
+ return undefined
+ }
+ return JSON.parse(serializedData)
+ } catch (err) {
+ return undefined
+ }
+}
+
+export function saveLocalStorageData (data, itemKey) {
+ try {
+ const serializedData = JSON.stringify(data)
+ localStorage.setItem(itemKey, serializedData)
+ } catch (err) {
+ console.warn(err)
+ }
+}