diff --git a/src/main/mobile/core.cljs b/src/main/mobile/core.cljs index 90d753b477..ea23aab2ee 100644 --- a/src/main/mobile/core.cljs +++ b/src/main/mobile/core.cljs @@ -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 diff --git a/src/main/mobile/navigation.cljs b/src/main/mobile/navigation.cljs index e1e4c1f611..36e2a774bb 100644 --- a/src/main/mobile/navigation.cljs +++ b/src/main/mobile/navigation.cljs @@ -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.