Skip to content

Commit

Permalink
fix(mobile): event handler for sync, android back button
Browse files Browse the repository at this point in the history
  • Loading branch information
andelf committed Jul 13, 2023
1 parent 54e346f commit 19358f0
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/main/frontend/mobile/core.cljs
Expand Up @@ -12,7 +12,8 @@
[frontend.state :as state]
[frontend.util :as util]
[cljs-bean.core :as bean]
[frontend.config :as config]))
[frontend.config :as config]
[frontend.handler.repo :as repo-handler]))

(def *url (atom nil))
;; FIXME: `appUrlOpen` are fired twice when receiving a same intent.
Expand Down Expand Up @@ -71,15 +72,15 @@
(.addListener App "backButton"
#(let [href js/window.location.href]
(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!)

(state/get-left-sidebar-open?)
(state/set-left-sidebar-open! false)

:else true))

(if (or (string/ends-with? href "#/")
Expand All @@ -103,7 +104,8 @@
(when (state/get-current-repo)
(let [is-active? (.-isActive state)]
(when-not is-active?
(editor-handler/save-current-block!))
(editor-handler/save-current-block!)
(repo-handler/persist-db!))
(state/set-mobile-app-state-change is-active?))))

(defn- general-init
Expand Down

0 comments on commit 19358f0

Please sign in to comment.