Fix bugs in new storage impl.

This commit is contained in:
Andrey Antukh 2016-04-15 23:39:04 +03:00
parent 3ab64e5a68
commit 8c996f3a57
No known key found for this signature in database
GPG key ID: 4DFEBCB8316A8B95
2 changed files with 9 additions and 11 deletions

View file

@ -18,7 +18,7 @@
{:dashboard {:project-order :name {:dashboard {:project-order :name
:project-filter ""} :project-filter ""}
:route nil :route nil
:auth (:auth storage nil) :auth (:uxbox/auth storage nil)
:clipboard #queue [] :clipboard #queue []
:profile nil :profile nil
:workspace nil :workspace nil

View file

@ -11,7 +11,7 @@
(defn- persist (defn- persist
[alias value] [alias value]
(let [key (name value) (let [key (name alias)
value (t/encode value)] value (t/encode value)]
(.setItem js/localStorage key value))) (.setItem js/localStorage key value)))
@ -19,12 +19,10 @@
[alias] [alias]
(if (= *target* "nodejs") (if (= *target* "nodejs")
{} {}
(when-let [data (.getItem js/localStorage (name alias))] (let [data (.getItem js/localStorage (name alias))]
(try (if data
(t/decode data) (t/decode data)
(catch js/Error e {}))))
(js/console.log (.-stack e))
{})))))
(defn make-storage (defn make-storage
[alias] [alias]
@ -46,13 +44,13 @@
ISwap ISwap
(-swap! [self f] (-swap! [self f]
(-swap! data f)) (swap! data f))
(-swap! [self f x] (-swap! [self f x]
(-swap! data f x)) (swap! data f x))
(-swap! [self f x y] (-swap! [self f x y]
(-swap! data f x y)) (swap! data f x y))
(-swap! [self f x y more] (-swap! [self f x y more]
(-swap! data f x y more)) (apply swap! data f x y more))
ILookup ILookup
(-lookup [_ key] (-lookup [_ key]