fix: notify native route changes and then ui refresh

This commit is contained in:
Tienson Qin
2025-11-24 09:37:54 +08:00
parent 2a24c4cc82
commit f2224e6a3f
2 changed files with 11 additions and 3 deletions

View File

@@ -29,6 +29,7 @@
[]
(.render root (app/main)))
(defonce ^:private *route-timeout (atom nil))
(defn set-router!
[]
(let [router (rf/router routes nil)]
@@ -36,14 +37,21 @@
router
(fn [route]
(let [route-name (get-in route [:data :name])
path (-> js/location .-hash (string/replace-first #"^#" ""))]
path (-> js/location .-hash (string/replace-first #"^#" ""))
pop? (= :pop @mobile-nav/navigation-source)
timeout @*route-timeout]
(when timeout
(js/clearTimeout timeout))
(mobile-nav/notify-route-change!
{:route {:to route-name
:path-params (:path-params route)
:query-params (:query-params route)}
:path path})
(route-handler/set-route-match! route)
(if pop?
(route-handler/set-route-match! route)
(reset! *route-timeout
(js/setTimeout #(route-handler/set-route-match! route) 200)))
(bottom-tabs/show!)
(case route-name

View File

@@ -5,7 +5,7 @@
[lambdaisland.glogi :as log]
[promesa.core :as p]))
(defonce ^:private navigation-source (atom nil))
(defonce navigation-source (atom nil))
(defonce ^:private initialised? (atom false))
;; Track whether the latest change came from a native back gesture / popstate.