From 8c996f3a57a4574098d508da2a4be72a55254e4c Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Fri, 15 Apr 2016 23:39:04 +0300 Subject: [PATCH] Fix bugs in new storage impl. --- src/uxbox/state.cljs | 2 +- src/uxbox/util/storage.cljs | 18 ++++++++---------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/uxbox/state.cljs b/src/uxbox/state.cljs index 048a053f9..95658dd2d 100644 --- a/src/uxbox/state.cljs +++ b/src/uxbox/state.cljs @@ -18,7 +18,7 @@ {:dashboard {:project-order :name :project-filter ""} :route nil - :auth (:auth storage nil) + :auth (:uxbox/auth storage nil) :clipboard #queue [] :profile nil :workspace nil diff --git a/src/uxbox/util/storage.cljs b/src/uxbox/util/storage.cljs index 6fa1eeeb7..264a68ba3 100644 --- a/src/uxbox/util/storage.cljs +++ b/src/uxbox/util/storage.cljs @@ -11,7 +11,7 @@ (defn- persist [alias value] - (let [key (name value) + (let [key (name alias) value (t/encode value)] (.setItem js/localStorage key value))) @@ -19,12 +19,10 @@ [alias] (if (= *target* "nodejs") {} - (when-let [data (.getItem js/localStorage (name alias))] - (try + (let [data (.getItem js/localStorage (name alias))] + (if data (t/decode data) - (catch js/Error e - (js/console.log (.-stack e)) - {}))))) + {})))) (defn make-storage [alias] @@ -46,13 +44,13 @@ ISwap (-swap! [self f] - (-swap! data f)) + (swap! data f)) (-swap! [self f x] - (-swap! data f x)) + (swap! data f x)) (-swap! [self f x y] - (-swap! data f x y)) + (swap! data f x y)) (-swap! [self f x y more] - (-swap! data f x y more)) + (apply swap! data f x y more)) ILookup (-lookup [_ key]