mirror of https://github.com/logseq/logseq
fix: page properties not cleared when cutting the first block
parent
3c0387040f
commit
6642b46cc8
|
@ -259,40 +259,6 @@
|
||||||
(and (not= current-id id)
|
(and (not= current-id id)
|
||||||
(db/entity [:block/uuid id]))))
|
(db/entity [:block/uuid id]))))
|
||||||
|
|
||||||
(defn- attach-page-properties-if-exists!
|
|
||||||
[block]
|
|
||||||
(if (and (:block/pre-block? block)
|
|
||||||
(seq (:block/properties block)))
|
|
||||||
(let [page-properties (:block/properties block)
|
|
||||||
str->page (fn [n] (block/page-name->map n true))
|
|
||||||
refs (->> page-properties
|
|
||||||
(filter (fn [[_ v]] (coll? v)))
|
|
||||||
(vals)
|
|
||||||
(apply concat)
|
|
||||||
(set)
|
|
||||||
(map str->page)
|
|
||||||
(concat (:block/refs block))
|
|
||||||
(util/distinct-by :block/name))
|
|
||||||
{:keys [tags alias]} page-properties
|
|
||||||
page-tx (let [id (:db/id (:block/page block))
|
|
||||||
retract-attributes (when id
|
|
||||||
(mapv (fn [attribute]
|
|
||||||
[:db/retract id attribute])
|
|
||||||
[:block/properties :block/tags :block/alias]))
|
|
||||||
tags (->> (map str->page tags) (remove nil?))
|
|
||||||
alias (->> (map str->page alias) (remove nil?))
|
|
||||||
tx (cond-> {:db/id id
|
|
||||||
:block/properties page-properties}
|
|
||||||
(seq tags)
|
|
||||||
(assoc :block/tags tags)
|
|
||||||
(seq alias)
|
|
||||||
(assoc :block/alias alias))]
|
|
||||||
(conj retract-attributes tx))]
|
|
||||||
(assoc block
|
|
||||||
:block/refs refs
|
|
||||||
:db/other-tx page-tx))
|
|
||||||
block))
|
|
||||||
|
|
||||||
(defn- remove-non-existed-refs!
|
(defn- remove-non-existed-refs!
|
||||||
[refs]
|
[refs]
|
||||||
(remove (fn [x] (or
|
(remove (fn [x] (or
|
||||||
|
@ -385,7 +351,6 @@
|
||||||
block
|
block
|
||||||
(dissoc block :block/pre-block?))
|
(dissoc block :block/pre-block?))
|
||||||
block (update block :block/refs remove-non-existed-refs!)
|
block (update block :block/refs remove-non-existed-refs!)
|
||||||
block (attach-page-properties-if-exists! block)
|
|
||||||
new-properties (merge
|
new-properties (merge
|
||||||
(select-keys properties (property/hidden-properties))
|
(select-keys properties (property/hidden-properties))
|
||||||
(:block/properties block))]
|
(:block/properties block))]
|
||||||
|
|
|
@ -158,12 +158,24 @@
|
||||||
db-schema/retract-attributes)))))
|
db-schema/retract-attributes)))))
|
||||||
|
|
||||||
(when-let [e (:block/page block-entity)]
|
(when-let [e (:block/page block-entity)]
|
||||||
(let [m {:db/id (:db/id e)
|
(let [m' {:db/id (:db/id e)
|
||||||
:block/updated-at (util/time-ms)}
|
:block/updated-at (util/time-ms)}
|
||||||
m (if (:block/created-at e)
|
m' (if (:block/created-at e)
|
||||||
m
|
m'
|
||||||
(assoc m :block/created-at (util/time-ms)))]
|
(assoc m' :block/created-at (util/time-ms)))
|
||||||
(swap! txs-state conj m))
|
m' (if (or (:block/pre-block? block-entity)
|
||||||
|
(:block/pre-block? m))
|
||||||
|
(let [properties (:block/properties m)
|
||||||
|
alias (set (:alias properties))
|
||||||
|
tags (set (:tags properties))
|
||||||
|
alias (map (fn [p] {:block/name (util/page-name-sanity-lc p)}) alias)
|
||||||
|
tags (map (fn [p] {:block/name (util/page-name-sanity-lc p)}) tags)]
|
||||||
|
(assoc m'
|
||||||
|
:block/alias alias
|
||||||
|
:block/tags tags
|
||||||
|
:block/properties properties))
|
||||||
|
m')]
|
||||||
|
(swap! txs-state conj m'))
|
||||||
(remove-orphaned-page-refs! (:db/id block-entity) txs-state old-refs new-refs)))
|
(remove-orphaned-page-refs! (:db/id block-entity) txs-state old-refs new-refs)))
|
||||||
|
|
||||||
(swap! txs-state conj (dissoc m :db/other-tx))
|
(swap! txs-state conj (dissoc m :db/other-tx))
|
||||||
|
@ -194,8 +206,16 @@
|
||||||
(assoc :block/left parent))))
|
(assoc :block/left parent))))
|
||||||
immediate-children)))
|
immediate-children)))
|
||||||
txs))
|
txs))
|
||||||
txs)]
|
txs)
|
||||||
(swap! txs-state concat txs)
|
page-tx (let [block (db/entity [:block/uuid block-id])]
|
||||||
|
(when (:block/pre-block? block)
|
||||||
|
(let [id (:db/id (:block/page block))]
|
||||||
|
[[:db/retract id :block/properties]
|
||||||
|
[:db/retract id :block/properties-order]
|
||||||
|
[:db/retract id :block/alias]
|
||||||
|
[:db/retract id :block/tags]])))]
|
||||||
|
(swap! txs-state concat txs page-tx)
|
||||||
|
(util/pprint @txs-state)
|
||||||
block-id))
|
block-id))
|
||||||
|
|
||||||
(-get-children [this]
|
(-get-children [this]
|
||||||
|
|
Loading…
Reference in New Issue