Skip to content

Commit

Permalink
Add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitaliy Vlasov committed Oct 4, 2019
1 parent 463aa9e commit a13d6a9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/status_im/ui/screens/navigation.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,14 @@
(assoc :prev-view-id (:view-id db)))}
(navigate-to-cofx view-id {}))))

;; This atom stores event vector
;; to be dispatched when a react-navigation's BACK
;; actions is invoked
(def wizard-back-event (atom nil))

;; This atom exists in order to avoid
;; endless loop when processing NavigationActions/BACK
;; in react-navigation's getStateForAction fn
(def processing-back-event? (atom false))

(fx/defn reset-processing-flag
Expand All @@ -151,6 +158,9 @@
(fn []
(reset! processing-back-event? false)))

;; Below two effects are added when we need
;; to override default react-navigation's BACK action
;; processing
(re-frame/reg-fx
::add-wizard-back-event
(fn [event]
Expand Down
6 changes: 5 additions & 1 deletion src/status_im/ui/screens/routing/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@
(prepare-config config)))
default-get-state-for-action (.-getStateForAction (.-router res))
new-get-state-for-action (fn [action state]
;; Override default getStateForAction on this stack navigator
;; if we have a custom event set in wizard-back-event atom
(if (and (= (.-type action) (.-BACK navigation/navigation-actions))
@screens.navigation/wizard-back-event)
(if @screens.navigation/processing-back-event?
Expand All @@ -151,6 +153,7 @@
(do
(reset! screens.navigation/processing-back-event? true)
(re-frame/dispatch @screens.navigation/wizard-back-event)
;; Return nil so that BACK event processing ends here
nil))
(default-get-state-for-action action state)))]
(set! (-> res .-router .-getStateForAction) new-get-state-for-action)
Expand Down Expand Up @@ -215,7 +218,8 @@
:else
(nav-reagent/stack-screen (wrap screen-name screen-config)))]
[screen-name (cond-> {:screen res}
;; TODO replace this hack with configuration
;; TODO issue #8947
;; replace this hack with configuration
(#{:create-multiaccount-choose-key
:recover-multiaccount-select-storage
:create-multiaccount-enable-notifications}
Expand Down

0 comments on commit a13d6a9

Please sign in to comment.