mirror of
https://github.com/penpot/penpot.git
synced 2025-06-10 09:11:42 +02:00
♻️ Refactor application initialization.
Fixes some bugs on development enviroment that causes two apps loading together.
This commit is contained in:
parent
e010bbb631
commit
2a8c1d5f03
2 changed files with 17 additions and 12 deletions
|
@ -42,13 +42,13 @@
|
||||||
(defn- on-navigate
|
(defn- on-navigate
|
||||||
[router path]
|
[router path]
|
||||||
(let [match (rt/match router path)]
|
(let [match (rt/match router path)]
|
||||||
;; (prn "on-navigate" path match)
|
(prn "main$on-navigate" path)
|
||||||
(cond
|
(cond
|
||||||
#_(and (= path "") (nil? match))
|
#_(and (= path "") (nil? match))
|
||||||
#_(html-history/set-path! "/dashboard/projects")
|
#_(html-history/set-path! "/dashboard/projects")
|
||||||
|
|
||||||
(nil? match)
|
(nil? match)
|
||||||
(prn "TODO 404")
|
(prn "TODO 404 main")
|
||||||
|
|
||||||
:else
|
:else
|
||||||
(st/emit! #(assoc % :route match)))))
|
(st/emit! #(assoc % :route match)))))
|
||||||
|
@ -70,8 +70,11 @@
|
||||||
|
|
||||||
(on-navigate router cpath)))
|
(on-navigate router cpath)))
|
||||||
|
|
||||||
|
(def app-sym (.for js/Symbol "uxbox.app"))
|
||||||
|
|
||||||
(defn ^:export init
|
(defn ^:export init
|
||||||
[]
|
[]
|
||||||
|
(unchecked-set js/window app-sym "main")
|
||||||
(st/init)
|
(st/init)
|
||||||
(init-ui))
|
(init-ui))
|
||||||
|
|
||||||
|
@ -85,4 +88,5 @@
|
||||||
|
|
||||||
(defn ^:after-load after-load
|
(defn ^:after-load after-load
|
||||||
[]
|
[]
|
||||||
(reinit))
|
(when (= "main" (unchecked-get js/window app-sym))
|
||||||
|
(reinit)))
|
||||||
|
|
|
@ -59,13 +59,10 @@
|
||||||
(defn- on-navigate
|
(defn- on-navigate
|
||||||
[router path]
|
[router path]
|
||||||
(let [match (rt/match router path)]
|
(let [match (rt/match router path)]
|
||||||
(prn "on-navigate" path match)
|
(prn "view$on-navigate" path)
|
||||||
(cond
|
(cond
|
||||||
;; (and (= path "") (nil? match))
|
|
||||||
;; (html-history/set-path! "/not-found")
|
|
||||||
|
|
||||||
(nil? match)
|
(nil? match)
|
||||||
(prn "TODO 404")
|
(prn "TODO 404 view" match)
|
||||||
|
|
||||||
:else
|
:else
|
||||||
(st/emit! #(assoc % :route match)))))
|
(st/emit! #(assoc % :route match)))))
|
||||||
|
@ -84,21 +81,25 @@
|
||||||
|
|
||||||
(on-navigate router cpath)))
|
(on-navigate router cpath)))
|
||||||
|
|
||||||
|
(def app-sym (.for js/Symbol "uxbox.app"))
|
||||||
|
|
||||||
(defn ^:export init
|
(defn ^:export init
|
||||||
[]
|
[]
|
||||||
|
(unchecked-set js/window app-sym "view")
|
||||||
(st/init)
|
(st/init)
|
||||||
(init-ui))
|
(init-ui))
|
||||||
|
|
||||||
(defn reinit
|
(defn reinit
|
||||||
[]
|
[]
|
||||||
(remove-watch html-history/path ::view)
|
(remove-watch html-history/path ::view)
|
||||||
(.unmountComponentAtNode js/ReactDOM (dom/get-element "app"))
|
(mf/unmount (dom/get-element "app"))
|
||||||
(.unmountComponentAtNode js/ReactDOM (dom/get-element "lightbox"))
|
(mf/unmount (dom/get-element "lightbox"))
|
||||||
(.unmountComponentAtNode js/ReactDOM (dom/get-element "loader"))
|
(mf/unmount (dom/get-element "loader"))
|
||||||
(init-ui))
|
(init-ui))
|
||||||
|
|
||||||
(defn ^:after-load after-load
|
(defn ^:after-load after-load
|
||||||
[]
|
[]
|
||||||
(reinit))
|
(when (= "view" (unchecked-get js/window app-sym))
|
||||||
|
(reinit)))
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue