From 500d2cc787ac3cf641d8138bbdba48ce080e5552 Mon Sep 17 00:00:00 2001 From: yenda Date: Mon, 14 Oct 2019 19:50:19 +0200 Subject: [PATCH] fix navigation reset currently navigation-reset only works properly if you reset to a simple route this fix allows us to use navigation reset with more complex routes, by ensuring that the navigation stack is populated properly so that navigate back doesn't end up emptying the stack. this is temporary as the proper way to do navigation in general would be to get rid of view id and navigation-stack entirely, since it is a duplication of the state of react-navigation Signed-off-by: yenda --- src/status_im/ui/screens/navigation.cljs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/status_im/ui/screens/navigation.cljs b/src/status_im/ui/screens/navigation.cljs index c8463cfe57..1668eba457 100644 --- a/src/status_im/ui/screens/navigation.cljs +++ b/src/status_im/ui/screens/navigation.cljs @@ -49,9 +49,13 @@ (fx/defn navigate-reset [{:keys [db]} {:keys [index actions] :as config}] - (let [view-id (:routeName (get actions index))] - {:db (assoc db :view-id view-id - :navigation-stack (list view-id)) + (let [stack (into '() (map :routeName actions)) + view-id (get stack index)] + {:db (assoc db + :view-id view-id + ;;NOTE: stricly needs to be a list + ;;because navigate-back pops it + :navigation-stack stack) ::navigate-reset config})) (def unload-data-interceptor @@ -158,7 +162,7 @@ (fn [] (reset! processing-back-event? false))) -;; Below two effects are added when we need +;; Below two effects are added when we need ;; to override default react-navigation's BACK action ;; processing (re-frame/reg-fx