fix reloading of views

This commit is contained in:
Roman Volosovskyi 2018-10-03 21:40:37 +03:00
parent 27667dd949
commit 34f8031d9f
No known key found for this signature in database
GPG Key ID: 0238A4B5ECEE70DE
1 changed files with 23 additions and 6 deletions

View File

@ -315,10 +315,11 @@
(defonce rand-label (rand/id)) (defonce rand-label (rand/id))
(defonce main-component (atom nil)) (defonce initial-view-id (atom nil))
(defn main [] (defn main []
(let [view-id (re-frame/subscribe [:get :view-id])] (let [view-id (re-frame/subscribe [:get :view-id])
main-component (atom nil)]
(reagent/create-class (reagent/create-class
{:component-did-mount {:component-did-mount
(fn [] (fn []
@ -326,14 +327,30 @@
(utils.universal-links/initialize)) (utils.universal-links/initialize))
:component-will-mount :component-will-mount
(fn [] (fn []
(when (and @view-id (not @main-component)) (when-not @initial-view-id
(reset! main-component (get-main-component2 @view-id)))) (reset! initial-view-id @view-id))
(when (and @initial-view-id
(or
js/goog.DEBUG
(not @main-component)))
(reset! main-component (get-main-component2
(if js/goog.DEBUG
@initial-view-id
@view-id)))))
:component-will-unmount :component-will-unmount
utils.universal-links/finalize utils.universal-links/finalize
:component-will-update :component-will-update
(fn [] (fn []
(when (and @view-id (not @main-component)) (when-not @initial-view-id
(reset! main-component (get-main-component2 @view-id))) (reset! initial-view-id @view-id))
(when (and @initial-view-id
(or
js/goog.DEBUG
(not @main-component)))
(reset! main-component (get-main-component2
(if js/goog.DEBUG
@initial-view-id
@view-id))))
(react/dismiss-keyboard!)) (react/dismiss-keyboard!))
:component-did-update :component-did-update
(fn [] (fn []