fix: can't open block on cmdk

pull/10933/head
Tienson Qin 2024-01-30 15:29:21 +08:00
parent 26d46485a0
commit 3fd30736b5
4 changed files with 22 additions and 15 deletions

View File

@ -29,7 +29,8 @@
[logseq.common.path :as path]
[electron.ipc :as ipc]
[frontend.util.text :as text-util]
[goog.userAgent]))
[goog.userAgent]
[frontend.db.async :as db-async]))
(defn translate [t {:keys [id desc]}]
(when id
@ -414,20 +415,22 @@
(state/close-modal!)))
(defmethod handle-action :open-block [_ state _event]
(let [block-id (some-> state state->highlighted-item :source-block :block/uuid)
get-block-page (partial model/get-block-page (state/get-current-repo))
block (db/entity [:block/uuid block-id])]
(when block
(when-let [page (some-> block-id get-block-page)]
(let [page-name (:block/name page)]
(cond
(= (:block/type page) "whiteboard")
(route-handler/redirect-to-whiteboard! page-name {:block-id block-id})
(model/parents-collapsed? (state/get-current-repo) block-id)
(route-handler/redirect-to-page! (:block/uuid block))
:else
(route-handler/redirect-to-page! page-name {:anchor (str "ls-block-" block-id)})))
(state/close-modal!)))))
(when-let [block-id (some-> state state->highlighted-item :source-block :block/uuid)]
(p/let [repo (state/get-current-repo)
_ (db-async/<get-block-and-children repo block-id)]
(let [get-block-page (partial model/get-block-page repo)
block (db/entity [:block/uuid block-id])]
(when block
(when-let [page (some-> block-id get-block-page)]
(let [page-name (:block/name page)]
(cond
(= (:block/type page) "whiteboard")
(route-handler/redirect-to-whiteboard! page-name {:block-id block-id})
(model/parents-collapsed? (state/get-current-repo) block-id)
(route-handler/redirect-to-page! block-id)
:else
(route-handler/redirect-to-page! page-name {:anchor (str "ls-block-" block-id)})))
(state/close-modal!)))))))
(defmethod handle-action :open-page-right [_ state _event]
(when-let [page-name (get-highlighted-page-name state)]

View File

@ -946,6 +946,7 @@ independent of format as format specific heading characters are stripped"
(sort-by :block/name)
(first))))
;; TODO: async query
(defn get-all-referenced-blocks-uuid
"Get all uuids of blocks with any back link exists."
[]
@ -982,6 +983,7 @@ independent of format as format specific heading characters are stripped"
:file/content content}]
(db-utils/transact! repo [tx-data] (merge opts {:skip-refresh? true}))))))
;; TODO: async query
(defn get-pre-block
[repo page-id]
(-> (d/q '[:find (pull ?b [*])

View File

@ -20,6 +20,7 @@
(->> (repeatedly 9 nano-id-char)
(str/join)))
;; TODO: async
(defn uuid->uid-map []
(let [db (db/get-db (state/get-current-repo))]
(->>

View File

@ -31,6 +31,7 @@
(gp-property/valid-property-name? (str k))) properties)
(into {}))))))
;; TODO: async query
(defn get-all-pages
"Get all pages and their children blocks."
[repo db]