diff --git a/src/main/frontend/mobile/core.cljs b/src/main/frontend/mobile/core.cljs index 2886f6b274..21807d1f53 100644 --- a/src/main/frontend/mobile/core.cljs +++ b/src/main/frontend/mobile/core.cljs @@ -1,5 +1,6 @@ (ns frontend.mobile.core (:require [frontend.mobile.util :as mobile-util] + [frontend.state :as state] ["@capacitor/app" :refer [^js App]] [reitit.frontend.easy :as rfe] [clojure.string :as string])) @@ -11,7 +12,20 @@ (when (mobile-util/native-android?) (.addListener App "backButton" #(let [href js/window.location.href] - (if (or (string/ends-with? href "#/") - (string/ends-with? href "/")) - (.exitApp App) - (js/window.history.back)))))) + (when (true? (cond + (state/get-left-sidebar-open?) + (state/set-left-sidebar-open! false) + + (state/settings-open?) + (state/close-settings!) + + (state/modal-opened?) + (state/close-modal!) + + :else true)) + + (if (or (string/ends-with? href "#/") + (string/ends-with? href "/") + (not (string/includes? href "#/"))) + (.exitApp App) + (js/window.history.back))))))) diff --git a/src/main/frontend/state.cljs b/src/main/frontend/state.cljs index 8d80249477..a7ada30c62 100644 --- a/src/main/frontend/state.cljs +++ b/src/main/frontend/state.cljs @@ -1399,6 +1399,10 @@ [] (toggle! :ui/settings-open?)) +(defn settings-open? + [] + (:ui/settings-open? @state)) + (defn close-settings! [] (set-state! :ui/settings-open? false))