enhance(iOS): save current block once switch to other app

Some users report data loss if close logseq immediately after edit,
the PR resoves this issue.
pull/3924/head
leizhe 2022-01-15 22:18:44 +08:00 committed by Tienson Qin
parent 78eb6366ef
commit 123f789429
1 changed files with 11 additions and 5 deletions

View File

@ -6,7 +6,10 @@
[clojure.string :as string]
[frontend.fs.capacitor-fs :as fs]
[frontend.components.repo :as repo]
[frontend.handler.web.nfs :as nfs-handler]))
[frontend.handler.web.nfs :as nfs-handler]
[frontend.handler.editor :as editor-handler]
[frontend.handler.notification :as notification]
[promesa.core :as p]))
(defn init!
[]
@ -42,7 +45,10 @@
#(state/pub-event! [:mobile/keyboard-did-show]))
(.addListener App "appStateChange"
#(when-let [repo (state/get-current-repo)]
(nfs-handler/refresh! repo repo/refresh-cb)
;; (notification/show! "Notes updated!" :success true)
))))
(fn [^js state]
(when-let [repo (state/get-current-repo)]
(let [is-active? (.-isActive state)]
(if is-active?
(p/do! (nfs-handler/refresh! repo repo/refresh-cb)
(notification/show! "Notes updated!" :success true))
(editor-handler/save-current-block!))))))))