fix: view-id not updating when navigating inside modals (#19163)

This commit is contained in:
Brian Sztamfater 2024-03-14 13:56:30 -03:00 committed by GitHub
parent 2a515a82ce
commit a06c5fdc02
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 8 deletions

View File

@ -37,14 +37,14 @@
(navigation/reg-component-did-appear-listener
(fn [view-id]
(when (get views/screens view-id)
;;NOTE when back from the background on Android, this event happens for all screens, but we
;;need only for active one
(when (and @state/curr-modal (= @state/curr-modal view-id))
(effects/set-view-id view-id))
(when-not @state/curr-modal
(let [view-id-with-prefix (keyword (str "screen/" (name view-id)))
view (or (get views/screens view-id)
(get views/screens view-id-with-prefix))
view-id (:name view)]
(when view
(effects/set-view-id view-id)
(reset! state/pushed-screen-id view-id)))))
(when-not @state/curr-modal
(reset! state/pushed-screen-id view-id))))))
;;;; Modal

View File

@ -33,7 +33,9 @@
(rf/defn navigate-to-within-stack
{:events [:navigate-to-within-stack]}
[{:keys [db]} comp-id]
{:db (update db :modal-view-ids add-view-to-modals (first comp-id))
{:db (-> db
(update :modal-view-ids add-view-to-modals (first comp-id))
(assoc :view-id (first comp-id)))
:fx [[:navigate-to-within-stack comp-id]]})
(re-frame/reg-event-fx :open-modal