From 34f8031d9f502a1978464c6d5a598e0a97d234c6 Mon Sep 17 00:00:00 2001 From: Roman Volosovskyi Date: Wed, 3 Oct 2018 21:40:37 +0300 Subject: [PATCH] fix reloading of views --- src/status_im/ui/screens/views.cljs | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/src/status_im/ui/screens/views.cljs b/src/status_im/ui/screens/views.cljs index 0e51f5d91f..7cd4fe12d7 100644 --- a/src/status_im/ui/screens/views.cljs +++ b/src/status_im/ui/screens/views.cljs @@ -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 []