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

View File

@ -33,7 +33,9 @@
(rf/defn navigate-to-within-stack (rf/defn navigate-to-within-stack
{:events [:navigate-to-within-stack]} {:events [:navigate-to-within-stack]}
[{:keys [db]} comp-id] [{: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]]}) :fx [[:navigate-to-within-stack comp-id]]})
(re-frame/reg-event-fx :open-modal (re-frame/reg-event-fx :open-modal