fix: can't save whiteboard updates

pull/11177/head
Tienson Qin 2024-04-24 17:59:01 +08:00
parent edef1ea6e6
commit 13edd74c2c
3 changed files with 26 additions and 26 deletions

View File

@ -31,7 +31,7 @@
(->> (d/datoms db :avet :block/name)
(keep (fn [e]
(when-not (contains? exclude-page-ids (:e e))
(d/pull db '[:db/id :block/uuid :block/name :block/original-name :block/alias :block/type] (:e e)))))))
(d/pull db '[:db/id :db/ident :block/uuid :block/name :block/original-name :block/alias :block/type] (:e e)))))))
(defn get-all-files
[db]

View File

@ -80,15 +80,14 @@
{:block/page page-id})))
(defn shape->block [repo shape page-id]
(let [properties {(db-property-util/get-pid repo :logseq.property/ls-type) :whiteboard-shape
(db-property-util/get-pid repo :logseq.property.tldraw/shape) shape}
(let [properties (if (sqlite-util/db-based-graph? repo)
[(sqlite-util/build-property-pair :logseq.property/ls-type :whiteboard-shape)
(sqlite-util/build-property-pair :logseq.property.tldraw/shape shape)]
{(db-property-util/get-pid repo :logseq.property/ls-type) :whiteboard-shape
(db-property-util/get-pid repo :logseq.property.tldraw/shape) shape})
block {:block/uuid (if (uuid? (:id shape)) (:id shape) (uuid (:id shape)))
:block/page page-id
:block/parent page-id}
properties' (merge properties {:ls-type :whiteboard-shape
:logseq.tldraw.shape shape})
block' (if (sqlite-util/db-based-graph? repo)
(merge block properties')
(assoc block :block/properties properties'))
block' (assoc block :block/properties properties)
additional-props (with-whiteboard-block-props block' page-id)]
(merge block' additional-props)))

View File

@ -20,13 +20,11 @@
[cljs-bean.core :as bean]
[logseq.db.sqlite.util :as sqlite-util]))
;; FIXME: no need to store :logseq.property/ls-type since it's stored already in `:block/type`
(defn js->clj-keywordize
[obj]
(js->clj obj :keywordize-keys true))
(defn shape->block [shape page-id]
(defn- shape->block [shape page-id]
(let [repo (state/get-current-repo)]
(gp-whiteboard/shape->block repo shape page-id)))
@ -58,17 +56,18 @@
(defn db-build-page-block
[page-entity page-name tldraw-page assets shapes-index]
(let [get-k #(gobj/get tldraw-page %)]
(let [get-k #(gobj/get tldraw-page %)
tldraw-page {:id (get-k "id")
:name (get-k "name")
:bindings (js->clj-keywordize (get-k "bindings"))
:nonce (get-k "nonce")
:assets (js->clj-keywordize assets)
:shapes-index shapes-index}]
{:block/original-name page-name
:block/name (util/page-name-sanity-lc page-name)
:block/type "whiteboard"
:logseq.property/ls-type :whiteboard-page
:logseq.property.tldraw/page {:id (get-k "id")
:name (get-k "name")
:bindings (js->clj-keywordize (get-k "bindings"))
:nonce (get-k "nonce")
:assets (js->clj-keywordize assets)
:shapes-index shapes-index}
:block/properties [(sqlite-util/build-property-pair :logseq.property/ls-type :whiteboard-page)
(sqlite-util/build-property-pair :logseq.property.tldraw/page tldraw-page)]
:block/updated-at (util/time-ms)
:block/created-at (or (:block/created-at page-entity)
(util/time-ms))}))
@ -206,14 +205,18 @@
(defn get-default-new-whiteboard-tx
[page-name id]
(let [properties {(pu/get-pid :logseq.property/ls-type) :whiteboard-page,
(pu/get-pid :logseq.property.tldraw/page)
{:id (str id),
(let [db-based? (config/db-based-graph? (state/get-current-repo))
tldraw-page {:id (str id),
:name page-name,
:ls-type :whiteboard-page,
:bindings {},
:nonce 1,
:assets []}}
:assets []}
properties (if db-based?
[(sqlite-util/build-property-pair :logseq.property/ls-type :whiteboard-page)
(sqlite-util/build-property-pair :logseq.property.tldraw/page tldraw-page)]
{(pu/get-pid :logseq.property/ls-type) :whiteboard-page,
(pu/get-pid :logseq.property.tldraw/page) tldraw-page})
m #:block{:uuid id
:name (util/page-name-sanity-lc page-name),
:original-name page-name
@ -222,9 +225,7 @@
:format :markdown
:updated-at (util/time-ms),
:created-at (util/time-ms)}]
(if (config/db-based-graph? (state/get-current-repo))
[(merge m properties)]
[(assoc m :block/properties properties)])))
[(assoc m :block/properties properties)]))
(defn <create-new-whiteboard-page!
([]