fix multiple set view-id events dispatched (#19083)
This commit is contained in:
parent
62f68ff44b
commit
e771d056a0
|
@ -21,6 +21,7 @@
|
||||||
[status-im.contexts.profile.push-notifications.events :as notifications]
|
[status-im.contexts.profile.push-notifications.events :as notifications]
|
||||||
[status-im.contexts.shell.jump-to.state :as shell.state]
|
[status-im.contexts.shell.jump-to.state :as shell.state]
|
||||||
[status-im.contexts.shell.jump-to.utils :as shell.utils]
|
[status-im.contexts.shell.jump-to.utils :as shell.utils]
|
||||||
|
[status-im.navigation.core :as navigation]
|
||||||
status-im.contexts.wallet.signals
|
status-im.contexts.wallet.signals
|
||||||
status-im.events
|
status-im.events
|
||||||
status-im.navigation.core
|
status-im.navigation.core
|
||||||
|
@ -44,7 +45,7 @@
|
||||||
|
|
||||||
(defn init
|
(defn init
|
||||||
[]
|
[]
|
||||||
|
(navigation/init)
|
||||||
(native-module/init #(re-frame/dispatch [:signals/signal-received %]))
|
(native-module/init #(re-frame/dispatch [:signals/signal-received %]))
|
||||||
(when platform/android?
|
(when platform/android?
|
||||||
(native-module/set-soft-input-mode adjust-resize))
|
(native-module/set-soft-input-mode adjust-resize))
|
||||||
|
|
|
@ -11,15 +11,17 @@
|
||||||
[status-im.navigation.view :as views]
|
[status-im.navigation.view :as views]
|
||||||
[utils.re-frame :as rf]))
|
[utils.re-frame :as rf]))
|
||||||
|
|
||||||
(navigation/set-lazy-component-registrator
|
(defn init
|
||||||
|
[]
|
||||||
|
(navigation/set-lazy-component-registrator
|
||||||
(fn [screen-key]
|
(fn [screen-key]
|
||||||
(let [screen (views/screen screen-key)]
|
(let [screen (views/screen screen-key)]
|
||||||
(navigation/register-component screen-key
|
(navigation/register-component screen-key
|
||||||
(fn [] (gesture/gesture-handler-root-hoc screen))
|
(fn [] (gesture/gesture-handler-root-hoc screen))
|
||||||
(fn [] screen)))))
|
(fn [] screen)))))
|
||||||
|
|
||||||
;; APP LAUNCHED
|
;; APP LAUNCHED
|
||||||
(navigation/reg-app-launched-listener
|
(navigation/reg-app-launched-listener
|
||||||
(fn []
|
(fn []
|
||||||
(navigation/set-default-options options/default-options)
|
(navigation/set-default-options options/default-options)
|
||||||
(reset! state/curr-modal false)
|
(reset! state/curr-modal false)
|
||||||
|
@ -33,7 +35,7 @@
|
||||||
(re-frame/dispatch [:chat/check-last-chat])))
|
(re-frame/dispatch [:chat/check-last-chat])))
|
||||||
(rn/hide-splash-screen)))
|
(rn/hide-splash-screen)))
|
||||||
|
|
||||||
(navigation/reg-component-did-appear-listener
|
(navigation/reg-component-did-appear-listener
|
||||||
(fn [view-id]
|
(fn [view-id]
|
||||||
(when (get views/screens view-id)
|
(when (get views/screens view-id)
|
||||||
;;NOTE when back from the background on Android, this event happens for all screens, but we
|
;;NOTE when back from the background on Android, this event happens for all screens, but we
|
||||||
|
@ -44,9 +46,9 @@
|
||||||
(effects/set-view-id view-id)
|
(effects/set-view-id view-id)
|
||||||
(reset! state/pushed-screen-id view-id)))))
|
(reset! state/pushed-screen-id view-id)))))
|
||||||
|
|
||||||
;;;; Modal
|
;;;; Modal
|
||||||
|
|
||||||
(navigation/reg-button-pressed-listener
|
(navigation/reg-button-pressed-listener
|
||||||
(fn [id]
|
(fn [id]
|
||||||
(if (= "dismiss-modal" id)
|
(if (= "dismiss-modal" id)
|
||||||
(do
|
(do
|
||||||
|
@ -56,7 +58,7 @@
|
||||||
(when-let [handler (get-in views/screens [(keyword id) :right-handler])]
|
(when-let [handler (get-in views/screens [(keyword id) :right-handler])]
|
||||||
(handler)))))
|
(handler)))))
|
||||||
|
|
||||||
(navigation/reg-modal-dismissed-listener
|
(navigation/reg-modal-dismissed-listener
|
||||||
(fn []
|
(fn []
|
||||||
(if (> (count @state/modals) 1)
|
(if (> (count @state/modals) 1)
|
||||||
(let [new-modals (butlast @state/modals)]
|
(let [new-modals (butlast @state/modals)]
|
||||||
|
@ -72,9 +74,9 @@
|
||||||
(when (keyword? component)
|
(when (keyword? component)
|
||||||
(effects/open-modal component)))))
|
(effects/open-modal component)))))
|
||||||
|
|
||||||
;;;; Toast
|
;;;; Toast
|
||||||
|
|
||||||
(navigation/register-component
|
(navigation/register-component
|
||||||
"toasts"
|
"toasts"
|
||||||
; `:flex 0` is the same as `flex: 0 0 auto` in CSS.
|
; `:flex 0` is the same as `flex: 0 0 auto` in CSS.
|
||||||
; We need this to override the HOC default layout which is
|
; We need this to override the HOC default layout which is
|
||||||
|
@ -85,12 +87,12 @@
|
||||||
#js {:flex 0})
|
#js {:flex 0})
|
||||||
(fn [] views/toasts))
|
(fn [] views/toasts))
|
||||||
|
|
||||||
;;;; Bottom sheet
|
;;;; Bottom sheet
|
||||||
|
|
||||||
(navigation/register-component
|
(navigation/register-component
|
||||||
"bottom-sheet"
|
"bottom-sheet"
|
||||||
(fn [] (gesture/gesture-handler-root-hoc views/bottom-sheet))
|
(fn [] (gesture/gesture-handler-root-hoc views/bottom-sheet))
|
||||||
(fn [] views/bottom-sheet))
|
(fn [] views/bottom-sheet)))
|
||||||
|
|
||||||
;; LEGACY (should be removed in status 2.0)
|
;; LEGACY (should be removed in status 2.0)
|
||||||
|
|
||||||
|
|
|
@ -129,12 +129,11 @@
|
||||||
|
|
||||||
(defn open-modal
|
(defn open-modal
|
||||||
[component]
|
[component]
|
||||||
(let [{:keys [options name]} (get views/screens component)
|
(let [{:keys [options]} (get views/screens component)
|
||||||
sheet? (:sheet? options)]
|
sheet? (:sheet? options)]
|
||||||
(if @state/dissmissing
|
(if @state/dissmissing
|
||||||
(reset! state/dissmissing component)
|
(reset! state/dissmissing component)
|
||||||
(do
|
(do
|
||||||
(set-view-id name) ; TODO https://github.com/status-im/status-mobile/issues/18811
|
|
||||||
(reset! state/curr-modal true)
|
(reset! state/curr-modal true)
|
||||||
(swap! state/modals conj component)
|
(swap! state/modals conj component)
|
||||||
(navigation/show-modal
|
(navigation/show-modal
|
||||||
|
|
Loading…
Reference in New Issue