fix: reactive linked block

This commit is contained in:
Tienson Qin
2023-08-16 12:53:49 +08:00
parent 172ee0ae24
commit cce7be9f50
2 changed files with 30 additions and 22 deletions

View File

@@ -2768,12 +2768,19 @@
(assoc config :level 0)))
(defn- build-block [config block* {:keys [navigating-block navigated?]}]
(let [block (if (or (and (:custom-query? config)
(empty? (:block/_parent block*))
(not (and (:dsl-query? config)
(string/includes? (:query config) "not"))))
navigated?)
(let [linked-block (:block/link (db/entity (:db/id block*)))
block (cond
(or (and (:custom-query? config)
(empty? (:block/_parent block*))
(not (and (:dsl-query? config)
(string/includes? (:query config) "not"))))
navigated?)
(db/entity [:block/uuid navigating-block])
linked-block
linked-block
:else
block*)]
(merge (db/sub-block (:db/id block))
(select-keys block [:block/level :block.temp/top? :block.temp/bottom?]))))
@@ -2905,7 +2912,7 @@
(defn- block-changed?
[old-block new-block]
(let [ks [:block/uuid :block/content :block/collapsed?
(let [ks [:block/uuid :block/content :block/collapsed? :block/link
:block/properties :block.temp/bottom? :block.temp/top?]]
(not
(and (= (select-keys old-block ks)

View File

@@ -420,22 +420,23 @@ independent of format as format specific heading characters are stripped"
(when-let [repo (state/get-current-repo)]
(->
(react/q repo [:frontend.db.react/block id]
{:query-fn (fn [_]
(let [e (db-utils/entity id)
children (map :db/id (sort-by-left (:block/_parent e) e))]
[e {:original-name (:block/original-name e)
:type (:block/type e)
:schema (:block/schema e)
:content (:block/content e)
:marker (:block/marker e)
:priority (:block/priority e)
:properties (:block/properties e)
:properties-values (:block/properties-text-values e)
:alias (:block/alias e)
:tags (:block/tags e)
:children children
:collapsed? (:block/collapsed? e)}]))}
nil)
{:query-fn (fn [_]
(let [e (db-utils/entity id)
children (map :db/id (sort-by-left (:block/_parent e) e))]
[e {:original-name (:block/original-name e)
:link (:block/link e)
:type (:block/type e)
:schema (:block/schema e)
:content (:block/content e)
:marker (:block/marker e)
:priority (:block/priority e)
:properties (:block/properties e)
:properties-values (:block/properties-text-values e)
:alias (:block/alias e)
:tags (:block/tags e)
:children children
:collapsed? (:block/collapsed? e)}]))}
nil)
react
first)))