mirror of
https://github.com/penpot/penpot.git
synced 2025-05-30 01:46:10 +02:00
✨ Minor improvements on app initialization.
This commit is contained in:
parent
e9d5eccd16
commit
c2847bec4d
3 changed files with 11 additions and 40 deletions
|
@ -18,7 +18,6 @@
|
|||
[uxbox.main.store :as st]
|
||||
[uxbox.main.ui :as ui]
|
||||
[uxbox.main.ui.modal :refer [modal]]
|
||||
[uxbox.main.ui.loader :refer [loader]]
|
||||
[uxbox.main.worker]
|
||||
[uxbox.util.dom :as dom]
|
||||
[uxbox.util.html.history :as html-history]
|
||||
|
@ -32,14 +31,17 @@
|
|||
|
||||
(defn- on-navigate
|
||||
[router path]
|
||||
(let [match (rt/match router path)]
|
||||
(cond
|
||||
(and (= path "") (:auth storage))
|
||||
(st/emit! (rt/nav :dashboard-projects))
|
||||
(let [match (rt/match router path)
|
||||
profile (:profile storage)]
|
||||
(prn "on-navigate" match path)
|
||||
|
||||
(and (= path "") (not (:auth storage)))
|
||||
(cond
|
||||
(and (= path "") (not profile))
|
||||
(st/emit! (rt/nav :login))
|
||||
|
||||
(and (= path "") profile)
|
||||
(st/emit! (rt/nav :dashboard-team {:team-id (:default-team-id profile)}))
|
||||
|
||||
(nil? match)
|
||||
(st/emit! (rt/nav :not-found))
|
||||
|
||||
|
@ -59,19 +61,15 @@
|
|||
|
||||
(mf/mount (mf/element ui/app) (dom/get-element "app"))
|
||||
(mf/mount (mf/element modal) (dom/get-element "modal"))
|
||||
(mf/mount (mf/element loader) (dom/get-element "loader"))
|
||||
|
||||
(on-navigate router cpath)))
|
||||
|
||||
(def app-sym (.for js/Symbol "uxbox.app"))
|
||||
|
||||
(defn ^:export init
|
||||
[]
|
||||
(let [translations (gobj/get goog.global "uxboxTranslations")
|
||||
themes (gobj/get goog.global "uxboxThemes")]
|
||||
(i18n/init! translations)
|
||||
(theme/init! themes)
|
||||
(unchecked-set js/window app-sym "main")
|
||||
(st/init)
|
||||
(init-ui)))
|
||||
|
||||
|
@ -80,11 +78,9 @@
|
|||
(remove-watch html-history/path ::main)
|
||||
(mf/unmount (dom/get-element "app"))
|
||||
(mf/unmount (dom/get-element "modal"))
|
||||
(mf/unmount (dom/get-element "loader"))
|
||||
(init-ui))
|
||||
|
||||
(defn ^:dev/after-load after-load
|
||||
[]
|
||||
(when (= "main" (unchecked-get js/window app-sym))
|
||||
(reinit)))
|
||||
(reinit))
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue