0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-09 00:10:11 -05:00

♻️ Refactor application initialization.

Fixes some bugs on development enviroment
that causes two apps loading together.
This commit is contained in:
Andrey Antukh 2019-07-24 11:34:15 +02:00
parent e010bbb631
commit 2a8c1d5f03
2 changed files with 17 additions and 12 deletions

View file

@ -42,13 +42,13 @@
(defn- on-navigate
[router path]
(let [match (rt/match router path)]
;; (prn "on-navigate" path match)
(prn "main$on-navigate" path)
(cond
#_(and (= path "") (nil? match))
#_(html-history/set-path! "/dashboard/projects")
(nil? match)
(prn "TODO 404")
(prn "TODO 404 main")
:else
(st/emit! #(assoc % :route match)))))
@ -70,8 +70,11 @@
(on-navigate router cpath)))
(def app-sym (.for js/Symbol "uxbox.app"))
(defn ^:export init
[]
(unchecked-set js/window app-sym "main")
(st/init)
(init-ui))
@ -85,4 +88,5 @@
(defn ^:after-load after-load
[]
(reinit))
(when (= "main" (unchecked-get js/window app-sym))
(reinit)))

View file

@ -59,13 +59,10 @@
(defn- on-navigate
[router path]
(let [match (rt/match router path)]
(prn "on-navigate" path match)
(prn "view$on-navigate" path)
(cond
;; (and (= path "") (nil? match))
;; (html-history/set-path! "/not-found")
(nil? match)
(prn "TODO 404")
(prn "TODO 404 view" match)
:else
(st/emit! #(assoc % :route match)))))
@ -84,21 +81,25 @@
(on-navigate router cpath)))
(def app-sym (.for js/Symbol "uxbox.app"))
(defn ^:export init
[]
(unchecked-set js/window app-sym "view")
(st/init)
(init-ui))
(defn reinit
[]
(remove-watch html-history/path ::view)
(.unmountComponentAtNode js/ReactDOM (dom/get-element "app"))
(.unmountComponentAtNode js/ReactDOM (dom/get-element "lightbox"))
(.unmountComponentAtNode js/ReactDOM (dom/get-element "loader"))
(mf/unmount (dom/get-element "app"))
(mf/unmount (dom/get-element "lightbox"))
(mf/unmount (dom/get-element "loader"))
(init-ui))
(defn ^:after-load after-load
[]
(reinit))
(when (= "view" (unchecked-get js/window app-sym))
(reinit)))