From 1b2a75ab251d6b5493b5a1d818e1d663f8558af6 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Wed, 24 Feb 2016 18:01:22 +0200 Subject: [PATCH] Fixed an other bug related to auth data management. --- src/uxbox/data/load.cljs | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/uxbox/data/load.cljs b/src/uxbox/data/load.cljs index cde41abcf..00f82a033 100644 --- a/src/uxbox/data/load.cljs +++ b/src/uxbox/data/load.cljs @@ -37,11 +37,11 @@ projects (into #{} (vals (:projects-by-id state))) shapes (into #{} (vals (:shapes-by-id state))) color-colls (into #{} (vals (:colors-by-id state)))] - (assoc! local-storage :data {:pages pages - :auth (:auth state) - :shapes shapes - :projects projects - :color-collections color-colls}))) + (assoc! local-storage ::auth (:auth state)) + (assoc! local-storage ::data {:pages pages + :shapes shapes + :projects projects + :color-collections color-colls}))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Events @@ -53,12 +53,14 @@ (reify rs/UpdateEvent (-apply-update [_ state] - (if-let [data (get local-storage :data nil)] - (as-> state $ - (reduce stpr/assoc-project $ (:projects data)) - (reduce stpr/assoc-page $ (:pages data)) - (reduce assoc-color $ (:color-collections data)) - (reduce assoc-shape $ (:shapes data)) - (assoc $ :auth (:auth data))) - state)))) + (let [auth (::auth local-storage) + data (::data local-storage) + state (assoc state :auth auth)] + (if data + (as-> state $ + (reduce stpr/assoc-project $ (:projects data)) + (reduce stpr/assoc-page $ (:pages data)) + (reduce assoc-color $ (:color-collections data)) + (reduce assoc-shape $ (:shapes data))) + state)))))