0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-10 08:50:57 -05:00

💄 Cosmetic fixes on storage ns.

This commit is contained in:
Andrey Antukh 2020-04-30 12:25:55 +02:00 committed by Alonso Torres
parent fac14be90a
commit d37a2766db

View file

@ -7,18 +7,21 @@
(ns uxbox.util.storage
(:require [uxbox.util.transit :as t]))
(defn- ^boolean is-worker?
[]
(or (= *target* "nodejs")
(not (exists? js/window))))
(defn- persist
[alias value]
(when-not (or (= *target* "nodejs")
(not (exists? js/window)))
(when-not (is-worker?)
(let [key (name alias)
value (t/encode value)]
(.setItem js/localStorage key value))))
(defn- load
[alias]
(when-not (or (= *target* "nodejs")
(not (exists? js/window)))
(when-not (is-worker?)
(let [data (.getItem js/localStorage (name alias))]
(try
(t/decode data)