fix: search for porperty block values leads to hidden page

Fixes LOG-2647
This commit is contained in:
Tienson Qin
2023-10-11 13:09:11 +08:00
parent ccc0bf9bad
commit c3e002aade
3 changed files with 21 additions and 1 deletions

View File

@@ -2602,7 +2602,12 @@
level-limit 3}
:as opts}]
(when block-id
(let [parents (db/get-block-parents repo block-id {:depth (inc level-limit)})
(let [block-id (or (when block-id
(some-> (property-handler/get-property-block-created-block [:block/uuid block-id])
db/entity
:block/uuid))
block-id)
parents (db/get-block-parents repo block-id {:depth (inc level-limit)})
page (or (db/get-block-page repo block-id) ;; only return for block uuid
(model/query-block-by-uuid block-id)) ;; return page entity when received page uuid
page-name (:block/name page)

View File

@@ -7,6 +7,7 @@
[frontend.components.search.highlight :as highlight]
[frontend.handler.route :as route-handler]
[frontend.handler.editor :as editor-handler]
[frontend.handler.property :as property-handler]
[frontend.handler.page :as page-handler]
[frontend.handler.notification :as notification]
[frontend.db :as db]
@@ -140,6 +141,11 @@
:block
(let [block-uuid (uuid (:block/uuid data))
block-uuid (or
(some-> (property-handler/get-property-block-created-block [:block/uuid block-uuid])
db/entity
:block/uuid)
block-uuid)
collapsed? (db/parents-collapsed? repo block-uuid)
page (:block/page (db/entity [:block/uuid block-uuid]))
page-name (:block/name page)]

View File

@@ -233,3 +233,12 @@
outliner-core/block-with-timestamps)]
{:page page-tx
:blocks [new-block]}))
(defn get-property-block-created-block
"Get the root block that created this property block."
[eid]
(let [b (db/entity eid)
from (get-in b [:block/metadata :created-from-block])]
(if from
(get-property-block-created-block [:block/uuid from])
(:db/id b))))