enhance: no need to block waiting previous graph server down

This commit is contained in:
Tienson Qin
2026-04-22 17:54:53 +08:00
parent 715deddeb0
commit 6e2acc0af1
3 changed files with 14 additions and 9 deletions

View File

@@ -102,7 +102,7 @@
[{:keys [state start-daemon! stop-daemon! runtime-ready?] :as manager} repo window-id]
(p/let [current-repo (get-in (ensure-state @state) [:window->repo window-id])
_ (when (and current-repo (not= current-repo repo))
(ensure-window-stopped! manager window-id))]
(js/setTimeout #(ensure-window-stopped! manager window-id) 0))]
(if-let [entry (get-in (ensure-state @state) [:repos repo])]
(p/let [runtime (:runtime entry)
ready? (runtime-ready? runtime)]

View File

@@ -48,7 +48,8 @@
[logseq.api.plugin :as plugin-api]
[logseq.db.frontend.schema :as db-schema]
[logseq.shui.ui :as shui]
[promesa.core :as p]))
[promesa.core :as p]
[cljs-time.core :as t]))
;; TODO: should we move all events here?
@@ -121,12 +122,15 @@
(search-plugin/call-service! service "search:rebuildBlocksIndice" {}))))))))
(defmethod handle :graph/switch [[_ graph opts]]
(p/do!
(export/cancel-db-backup!)
(state/set-state! :db/async-queries {})
(st/refresh!)
(graph-switch-on-persisted graph opts)
(export/backup-db-graph (state/get-current-repo))))
(let [t1 (t/now)]
(p/do!
(export/cancel-db-backup!)
(state/set-state! :db/async-queries {})
(st/refresh!)
(graph-switch-on-persisted graph opts)
(export/backup-db-graph (state/get-current-repo))
(let [t2 (t/now)]
(log/info ::graph-switch-spent (- t2 t1))))))
(defmethod handle :graph/open-new-window [[_ev target-repo]]
(ui-handler/open-new-window-or-tab! target-repo))

View File

@@ -214,7 +214,8 @@
(defn backup-db-graph
[repo]
(when-not (util/capacitor?)
(when (and util/web-platform?
(not (util/capacitor?)))
(web-backup-db-graph repo)))
(defonce *backup-interval (atom nil))