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 main-component (atom nil))
(defonce initial-view-id (atom nil))
(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
{:component-did-mount
(fn []
@ -326,14 +327,30 @@
(utils.universal-links/initialize))
:component-will-mount
(fn []
(when (and @view-id (not @main-component))
(reset! main-component (get-main-component2 @view-id))))
(when-not @initial-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
utils.universal-links/finalize
:component-will-update
(fn []
(when (and @view-id (not @main-component))
(reset! main-component (get-main-component2 @view-id)))
(when-not @initial-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!))
:component-did-update
(fn []