Skip to content

Commit

Permalink
fix navigation reset
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
yenda committed Oct 16, 2019
1 parent 1314c6e commit 500d2cc
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/status_im/ui/screens/navigation.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 500d2cc

Please sign in to comment.