From 4e382d456f99fc5325da90837bc24a3bcaa70b14 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Wed, 24 Jul 2019 13:29:07 +0200 Subject: [PATCH] :bug: Fix initial page loading. --- frontend/src/uxbox/main.cljs | 8 ++++++-- frontend/src/uxbox/util/i18n.cljs | 8 ++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/frontend/src/uxbox/main.cljs b/frontend/src/uxbox/main.cljs index 4089b7ccd9..6f40b262c6 100644 --- a/frontend/src/uxbox/main.cljs +++ b/frontend/src/uxbox/main.cljs @@ -43,9 +43,13 @@ [router path] (let [match (rt/match router path)] (prn "main$on-navigate" path) + (cond - #_(and (= path "") (nil? match)) - #_(html-history/set-path! "/dashboard/projects") + (and (= path "") (:auth storage)) + (st/emit! (rt/nav :dashboard/projects)) + + (and (= path "") (not (:auth storage))) + (st/emit! (rt/nav :auth/login)) (nil? match) (prn "TODO 404 main") diff --git a/frontend/src/uxbox/util/i18n.cljs b/frontend/src/uxbox/util/i18n.cljs index e1e91839b0..c07946ba78 100644 --- a/frontend/src/uxbox/util/i18n.cljs +++ b/frontend/src/uxbox/util/i18n.cljs @@ -14,10 +14,6 @@ (defonce locale (atom (get storage ::locale cfg/default-language))) (defonce state (atom {})) -(defn set-default-locale! - [] - (set-current-locale! cfg/default-language)) - (defn update-locales! [callback] (swap! state callback)) @@ -27,6 +23,10 @@ (swap! storage assoc ::locale v) (reset! locale v)) +(defn set-default-locale! + [] + (set-current-locale! cfg/default-language)) + (defn on-locale-change! [callback] (add-watch locale ::main (fn [_ _ old-locale new-locale]