mirror of
https://github.com/logseq/logseq.git
synced 2026-02-01 14:43:56 +00:00
refactor: prefer conn than repo for outliner core and rtc update
This commit is contained in:
129
deps/outliner/src/logseq/outliner/core.cljs
vendored
129
deps/outliner/src/logseq/outliner/core.cljs
vendored
@@ -12,14 +12,12 @@
|
||||
[logseq.db :as ldb]
|
||||
[logseq.db.common.entity-plus :as entity-plus]
|
||||
[logseq.db.common.order :as db-order]
|
||||
[logseq.db.file-based.schema :as file-schema]
|
||||
[logseq.db.frontend.class :as db-class]
|
||||
[logseq.db.frontend.schema :as db-schema]
|
||||
[logseq.db.sqlite.create-graph :as sqlite-create-graph]
|
||||
[logseq.db.sqlite.util :as sqlite-util]
|
||||
[logseq.graph-parser.block :as gp-block]
|
||||
[logseq.graph-parser.db :as gp-db]
|
||||
[logseq.graph-parser.property :as gp-property]
|
||||
[logseq.outliner.batch-tx :include-macros true :as batch-tx]
|
||||
[logseq.outliner.datascript :as ds]
|
||||
[logseq.outliner.pipeline :as outliner-pipeline]
|
||||
@@ -28,8 +26,6 @@
|
||||
[malli.core :as m]
|
||||
[malli.util :as mu]))
|
||||
|
||||
;; TODO: remove `repo` usage, use db to check `entity-plus/db-based-graph?`
|
||||
|
||||
(def ^:private block-map
|
||||
(mu/optional-keys
|
||||
[:map
|
||||
@@ -299,25 +295,22 @@
|
||||
|
||||
(extend-type Entity
|
||||
otree/INode
|
||||
(-save [this *txs-state db repo _date-formatter {:keys [retract-attributes? retract-attributes outliner-op]
|
||||
(-save [this *txs-state db {:keys [retract-attributes? retract-attributes outliner-op]
|
||||
:or {retract-attributes? true}}]
|
||||
(assert (ds/outliner-txs-state? *txs-state)
|
||||
"db should be satisfied outliner-tx-state?")
|
||||
(let [db-based? (sqlite-util/db-based-graph? repo)
|
||||
data (if (de/entity? this)
|
||||
(let [data (if (de/entity? this)
|
||||
(assoc (.-kv ^js this) :db/id (:db/id this))
|
||||
this)
|
||||
data' (if db-based?
|
||||
(->> (dissoc data :block/properties)
|
||||
data' (->> (dissoc data :block/properties)
|
||||
(remove-disallowed-inline-classes db))
|
||||
data)
|
||||
collapse-or-expand? (= outliner-op :collapse-expand-blocks)
|
||||
m* (cond->
|
||||
(-> data'
|
||||
(dissoc :block/children :block/meta :block/unordered
|
||||
:block.temp/ast-title :block.temp/ast-body :block/level :block.temp/load-status
|
||||
:block.temp/has-children?)
|
||||
(fix-tag-ids db {:db-graph? db-based?}))
|
||||
(fix-tag-ids db {:db-graph? true}))
|
||||
(not collapse-or-expand?)
|
||||
block-with-updated-at)
|
||||
db-id (:db/id this)
|
||||
@@ -325,28 +318,27 @@
|
||||
eid (or db-id (when block-uuid [:block/uuid block-uuid]))
|
||||
block-entity (d/entity db eid)
|
||||
page? (ldb/page? block-entity)
|
||||
m* (if (and db-based? (:block/title m*)
|
||||
m* (if (and (:block/title m*)
|
||||
(not (:logseq.property.node/display-type block-entity)))
|
||||
(update m* :block/title common-util/clear-markdown-heading)
|
||||
m*)
|
||||
block-title (:block/title m*)
|
||||
page-title-changed? (and page? block-title
|
||||
(not= block-title (:block/title block-entity)))
|
||||
_ (when (and db-based? page? block-title)
|
||||
_ (when (and page? block-title)
|
||||
(outliner-validate/validate-page-title-characters block-title {:node m*}))
|
||||
m* (if (and db-based? page-title-changed?)
|
||||
m* (if page-title-changed?
|
||||
(let [_ (outliner-validate/validate-page-title (:block/title m*) {:node m*})
|
||||
page-name (common-util/page-name-sanity-lc (:block/title m*))]
|
||||
(assoc m* :block/name page-name))
|
||||
m*)
|
||||
_ (when (and db-based?
|
||||
;; page or object changed?
|
||||
_ (when (and ;; page or object changed?
|
||||
(or (ldb/page? block-entity) (ldb/object? block-entity))
|
||||
(:block/title m*)
|
||||
(not= (:block/title m*) (:block/title block-entity)))
|
||||
(outliner-validate/validate-block-title db (:block/title m*) block-entity))
|
||||
m (cond-> m*
|
||||
db-based?
|
||||
true
|
||||
(dissoc :block/format :block/pre-block? :block/priority :block/marker :block/properties-order))]
|
||||
;; Ensure block UUID never changes
|
||||
(let [e (d/entity db db-id)]
|
||||
@@ -361,9 +353,7 @@
|
||||
(when (or (and retract-attributes? (:block/title m))
|
||||
(seq retract-attributes))
|
||||
(let [retract-attributes (concat
|
||||
(if db-based?
|
||||
db-schema/retract-attributes
|
||||
file-schema/retract-attributes)
|
||||
retract-attributes)]
|
||||
(swap! *txs-state (fn [txs]
|
||||
(vec
|
||||
@@ -377,7 +367,7 @@
|
||||
(update-page-when-save-block *txs-state block-entity m))
|
||||
;; Remove orphaned refs from block
|
||||
(when (and (:block/title m) (not= (:block/title m) (:block/title block-entity)))
|
||||
(remove-orphaned-refs-when-save db *txs-state block-entity m {:db-graph? db-based?})))
|
||||
(remove-orphaned-refs-when-save db *txs-state block-entity m {:db-graph? true})))
|
||||
|
||||
;; handle others txs
|
||||
(let [other-tx (:db/other-tx m)]
|
||||
@@ -387,16 +377,15 @@
|
||||
(swap! *txs-state conj
|
||||
(dissoc m :db/other-tx)))
|
||||
|
||||
(when (and db-based? (:block/tags block-entity) block-entity)
|
||||
(when (and (:block/tags block-entity) block-entity)
|
||||
(let [;; delete tags when title changed
|
||||
tx-data (remove-tags-when-title-changed block-entity (:block/title m))]
|
||||
(when (seq tx-data)
|
||||
(swap! *txs-state (fn [txs] (concat txs tx-data))))))
|
||||
|
||||
(when db-based?
|
||||
(let [tx-data (add-missing-tag-idents db (:block/tags m))]
|
||||
(when (seq tx-data)
|
||||
(swap! *txs-state (fn [txs] (concat txs tx-data))))))
|
||||
(swap! *txs-state (fn [txs] (concat txs tx-data)))))
|
||||
|
||||
this))
|
||||
|
||||
@@ -519,7 +508,7 @@
|
||||
|
||||
(defn ^:api save-block
|
||||
"Save the `block`."
|
||||
[repo db date-formatter block opts]
|
||||
[db block opts]
|
||||
{:pre [(map? block)]}
|
||||
(let [*txs-state (atom [])
|
||||
block' (if (de/entity? block)
|
||||
@@ -530,7 +519,7 @@
|
||||
(let [ent (d/entity db eid)]
|
||||
(assert (some? ent) "save-block entity not exists")
|
||||
(merge ent block)))))]
|
||||
(otree/-save block' *txs-state db repo date-formatter opts)
|
||||
(otree/-save block' *txs-state db opts)
|
||||
{:tx-data @*txs-state}))
|
||||
|
||||
(defn- get-right-siblings
|
||||
@@ -543,28 +532,19 @@
|
||||
rest))))
|
||||
|
||||
(defn- blocks-with-ordered-list-props
|
||||
[repo blocks target-block sibling?]
|
||||
[blocks target-block sibling?]
|
||||
(let [target-block (if sibling? target-block (when target-block (ldb/get-down target-block)))
|
||||
list-type-fn (fn [block]
|
||||
(if (sqlite-util/db-based-graph? repo)
|
||||
;; Get raw id since insert-blocks doesn't auto-handle raw property values
|
||||
(:db/id (:logseq.property/order-list-type block))
|
||||
(get (:block/properties block) :logseq.order-list-type)))
|
||||
db-based? (sqlite-util/db-based-graph? repo)]
|
||||
(:db/id (:logseq.property/order-list-type block)))]
|
||||
(if-let [list-type (and target-block (list-type-fn target-block))]
|
||||
(mapv
|
||||
(fn [{:block/keys [title format] :as block}]
|
||||
(fn [block]
|
||||
(let [list?' (and (some? (:block/uuid block))
|
||||
(nil? (list-type-fn block)))]
|
||||
(cond-> block
|
||||
list?'
|
||||
((fn [b]
|
||||
(if db-based?
|
||||
(assoc b :logseq.property/order-list-type list-type)
|
||||
(update b :block/properties assoc :logseq.order-list-type list-type))))
|
||||
|
||||
(not db-based?)
|
||||
(assoc :block/title (gp-property/insert-property repo format title :logseq.order-list-type list-type)))))
|
||||
(assoc b :logseq.property/order-list-type list-type))))))
|
||||
blocks)
|
||||
blocks)))
|
||||
|
||||
@@ -615,13 +595,12 @@
|
||||
|
||||
(defn- build-insert-blocks-tx
|
||||
[db target-block blocks uuids get-new-id {:keys [sibling? outliner-op replace-empty-target? insert-template? keep-block-order?]}]
|
||||
(let [db-based? (entity-plus/db-based-graph? db)
|
||||
block-ids (set (map :block/uuid blocks))
|
||||
(let [block-ids (set (map :block/uuid blocks))
|
||||
target-page (get-target-block-page target-block sibling?)
|
||||
orders (get-block-orders blocks target-block sibling? keep-block-order?)]
|
||||
(map-indexed (fn [idx {:block/keys [parent] :as block}]
|
||||
(when-let [uuid' (get uuids (:block/uuid block))]
|
||||
(let [block (if db-based? (remove-disallowed-inline-classes db block) block)
|
||||
(let [block (remove-disallowed-inline-classes db block)
|
||||
top-level? (= (:block/level block) 1)
|
||||
parent (compute-block-parent block parent target-block top-level? sibling? get-new-id outliner-op replace-empty-target? idx)
|
||||
|
||||
@@ -790,7 +769,7 @@
|
||||
to replace it, it defaults to be `false`.
|
||||
`update-timestamps?`: whether to update `blocks` timestamps.
|
||||
``"
|
||||
[repo db blocks target-block {:keys [_sibling? keep-uuid? keep-block-order?
|
||||
[db blocks target-block {:keys [_sibling? keep-uuid? keep-block-order?
|
||||
outliner-op outliner-real-op replace-empty-target? update-timestamps?
|
||||
insert-template?]
|
||||
:as opts
|
||||
@@ -828,16 +807,15 @@
|
||||
(and sibling?
|
||||
(:block/title target-block)
|
||||
(string/blank? (:block/title target-block))
|
||||
(> (count blocks) 1)))
|
||||
db-based? (sqlite-util/db-based-graph? repo)]
|
||||
(> (count blocks) 1)))]
|
||||
(when (seq blocks)
|
||||
(let [blocks' (let [blocks' (blocks-with-level blocks)]
|
||||
(cond->> (blocks-with-ordered-list-props repo blocks' target-block sibling?)
|
||||
(cond->> (blocks-with-ordered-list-props blocks' target-block sibling?)
|
||||
update-timestamps?
|
||||
(mapv #(dissoc % :block/created-at :block/updated-at))
|
||||
true
|
||||
(mapv block-with-timestamps)
|
||||
db-based?
|
||||
true
|
||||
(mapv #(-> % (dissoc :block/properties)))))
|
||||
insert-opts {:sibling? sibling?
|
||||
:replace-empty-target? replace-empty-target?
|
||||
@@ -999,7 +977,7 @@
|
||||
|
||||
(defn- move-blocks
|
||||
"Move `blocks` to `target-block` as siblings or children."
|
||||
[_repo conn blocks target-block {:keys [_sibling? _top? _bottom? _up? outliner-op _indent?]
|
||||
[conn blocks target-block {:keys [_sibling? _top? _bottom? _up? outliner-op _indent?]
|
||||
:as opts}]
|
||||
{:pre [(seq blocks)
|
||||
(m/validate block-map-or-entity target-block)]}
|
||||
@@ -1039,7 +1017,7 @@
|
||||
|
||||
(defn- move-blocks-up-down
|
||||
"Move blocks up/down."
|
||||
[repo conn blocks up?]
|
||||
[conn blocks up?]
|
||||
{:pre [(seq blocks) (boolean? up?)]}
|
||||
(let [db @conn
|
||||
top-level-blocks (filter-top-level-blocks db blocks)
|
||||
@@ -1058,7 +1036,7 @@
|
||||
(:db/id left-left))
|
||||
(not (and (:logseq.property/created-from-property first-block)
|
||||
(nil? first-block-left-sibling))))
|
||||
(move-blocks repo conn top-level-blocks left-left (merge opts {:sibling? sibling?
|
||||
(move-blocks conn top-level-blocks left-left (merge opts {:sibling? sibling?
|
||||
:up? up?}))))
|
||||
|
||||
(let [last-top-block (last top-level-blocks)
|
||||
@@ -1072,12 +1050,12 @@
|
||||
(when (and right
|
||||
(not (and (:logseq.property/created-from-property last-top-block)
|
||||
(nil? last-top-block-right))))
|
||||
(move-blocks repo conn blocks right (merge opts {:sibling? sibling?
|
||||
(move-blocks conn blocks right (merge opts {:sibling? sibling?
|
||||
:up? up?})))))))
|
||||
|
||||
(defn- ^:large-vars/cleanup-todo indent-outdent-blocks
|
||||
"Indent or outdent `blocks`."
|
||||
[repo conn blocks indent? & {:keys [parent-original logical-outdenting?]}]
|
||||
[conn blocks indent? & {:keys [parent-original logical-outdenting?]}]
|
||||
{:pre [(seq blocks) (boolean? indent?)]}
|
||||
(let [db @conn
|
||||
top-level-blocks (filter-top-level-blocks db blocks)
|
||||
@@ -1105,21 +1083,21 @@
|
||||
(when (seq blocks')
|
||||
(if last-direct-child-id
|
||||
(let [last-direct-child (d/entity db last-direct-child-id)
|
||||
result (move-blocks repo conn blocks' last-direct-child (merge opts {:sibling? true
|
||||
result (move-blocks conn blocks' last-direct-child (merge opts {:sibling? true
|
||||
:indent? true}))
|
||||
;; expand `left` if it's collapsed
|
||||
collapsed-tx (when (:block/collapsed? left)
|
||||
{:tx-data [{:db/id (:db/id left)
|
||||
:block/collapsed? false}]})]
|
||||
(concat-tx-fn result collapsed-tx))
|
||||
(move-blocks repo conn blocks' left (merge opts {:sibling? false
|
||||
(move-blocks conn blocks' left (merge opts {:sibling? false
|
||||
:indent? true}))))))
|
||||
(if parent-original
|
||||
(let [blocks' (take-while (fn [b]
|
||||
(not= (:db/id (:block/parent b))
|
||||
(:db/id (:block/parent parent))))
|
||||
top-level-blocks)]
|
||||
(move-blocks repo conn blocks' parent-original (merge opts {:outliner-op :indent-outdent-blocks
|
||||
(move-blocks conn blocks' parent-original (merge opts {:outliner-op :indent-outdent-blocks
|
||||
:sibling? true
|
||||
:indent? false})))
|
||||
|
||||
@@ -1128,7 +1106,7 @@
|
||||
(not= (:db/id (:block/parent b))
|
||||
(:db/id (:block/parent parent))))
|
||||
top-level-blocks)
|
||||
result (move-blocks repo conn blocks' parent (merge opts {:sibling? true}))]
|
||||
result (move-blocks conn blocks' parent (merge opts {:sibling? true}))]
|
||||
(if logical-outdenting?
|
||||
result
|
||||
;; direct outdenting (default behavior)
|
||||
@@ -1136,8 +1114,8 @@
|
||||
right-siblings (get-right-siblings last-top-block)]
|
||||
(if (seq right-siblings)
|
||||
(if-let [last-direct-child-id (ldb/get-block-last-direct-child-id db (:db/id last-top-block))]
|
||||
(move-blocks repo conn right-siblings (d/entity db last-direct-child-id) (merge opts {:sibling? true}))
|
||||
(move-blocks repo conn right-siblings last-top-block (merge opts {:sibling? false})))
|
||||
(move-blocks conn right-siblings (d/entity db last-direct-child-id) (merge opts {:sibling? true}))
|
||||
(move-blocks conn right-siblings last-top-block (merge opts {:sibling? false})))
|
||||
result)))))))))))
|
||||
|
||||
;;; ### write-operations have side-effects (do transactions) ;;;;;;;;;;;;;;;;
|
||||
@@ -1150,44 +1128,45 @@
|
||||
(when result
|
||||
(let [tx-meta (assoc (:tx-meta result)
|
||||
:outliner-op outliner-op)]
|
||||
(ldb/transact! (second args) (:tx-data result) tx-meta)))
|
||||
(ldb/transact! (first args) (:tx-data result) tx-meta)))
|
||||
result)
|
||||
(catch :default e
|
||||
(js/console.error e)
|
||||
(when-not (= "not-allowed-move-block-page" (ex-message e))
|
||||
(throw e)))))
|
||||
|
||||
(let [f (fn [repo conn date-formatter block opts]
|
||||
(save-block repo @conn date-formatter block opts))]
|
||||
(let [f (fn [conn block opts]
|
||||
(save-block @conn block opts))]
|
||||
(defn save-block!
|
||||
[repo conn date-formatter block & {:as opts}]
|
||||
(op-transact! :save-block f repo conn date-formatter block opts)))
|
||||
[conn block & {:as opts}]
|
||||
(op-transact! :save-block f conn block opts)))
|
||||
|
||||
(let [f (fn [repo conn blocks target-block opts]
|
||||
(insert-blocks repo @conn blocks target-block opts))]
|
||||
(let [f (fn [conn blocks target-block opts]
|
||||
(insert-blocks @conn blocks target-block opts))]
|
||||
(defn insert-blocks!
|
||||
[repo conn blocks target-block opts]
|
||||
(op-transact! :insert-blocks f repo conn blocks target-block
|
||||
[conn blocks target-block opts]
|
||||
(op-transact! :insert-blocks f conn blocks target-block
|
||||
(if (:outliner-op opts)
|
||||
opts
|
||||
(assoc opts :outliner-op :insert-blocks)))))
|
||||
|
||||
(let [f (fn [_repo conn blocks _opts]
|
||||
(let [f (fn [conn blocks _opts]
|
||||
(delete-blocks @conn blocks))]
|
||||
(defn delete-blocks!
|
||||
[repo conn _date-formatter blocks opts]
|
||||
(op-transact! :delete-blocks f repo conn blocks opts)))
|
||||
[conn blocks opts]
|
||||
(op-transact! :delete-blocks f conn blocks opts)))
|
||||
|
||||
(defn move-blocks!
|
||||
[repo conn blocks target-block opts]
|
||||
(op-transact! :move-blocks move-blocks repo conn blocks target-block
|
||||
[conn blocks target-block opts]
|
||||
(op-transact! :move-blocks move-blocks conn blocks target-block
|
||||
(if (:outliner-op opts)
|
||||
opts
|
||||
(assoc opts :outliner-op :move-blocks))))
|
||||
|
||||
(defn move-blocks-up-down!
|
||||
[repo conn blocks up?]
|
||||
(op-transact! :move-blocks-up-down move-blocks-up-down repo conn blocks up?))
|
||||
[conn blocks up?]
|
||||
(op-transact! :move-blocks-up-down move-blocks-up-down conn blocks up?))
|
||||
|
||||
(defn indent-outdent-blocks!
|
||||
[repo conn blocks indent? & {:as opts}]
|
||||
(op-transact! :indent-outdent-blocks indent-outdent-blocks repo conn blocks indent? opts))
|
||||
[conn blocks indent? & {:as opts}]
|
||||
(op-transact! :indent-outdent-blocks indent-outdent-blocks conn blocks indent? opts))
|
||||
|
||||
16
deps/outliner/src/logseq/outliner/op.cljs
vendored
16
deps/outliner/src/logseq/outliner/op.cljs
vendored
@@ -169,7 +169,7 @@
|
||||
(reset! *result {:error (str "Unexpected Import EDN error: " (pr-str (ex-message e)))}))))))
|
||||
|
||||
(defn ^:large-vars/cleanup-todo apply-ops!
|
||||
[repo conn ops date-formatter opts]
|
||||
[conn ops opts]
|
||||
(assert (ops-validator ops) ops)
|
||||
(let [opts' (assoc opts
|
||||
:transact-opts {:conn conn}
|
||||
@@ -181,37 +181,37 @@
|
||||
(case op
|
||||
;; blocks
|
||||
:save-block
|
||||
(apply outliner-core/save-block! repo conn date-formatter args)
|
||||
(apply outliner-core/save-block! conn args)
|
||||
|
||||
:insert-blocks
|
||||
(let [[blocks target-block-id opts] args]
|
||||
(when-let [target-block (d/entity @conn target-block-id)]
|
||||
(let [result (outliner-core/insert-blocks! repo conn blocks target-block opts)]
|
||||
(let [result (outliner-core/insert-blocks! conn blocks target-block opts)]
|
||||
(reset! *result result))))
|
||||
|
||||
:delete-blocks
|
||||
(let [[block-ids opts] args
|
||||
blocks (keep #(d/entity @conn %) block-ids)]
|
||||
(outliner-core/delete-blocks! repo conn date-formatter blocks (merge opts opts')))
|
||||
(outliner-core/delete-blocks! conn blocks (merge opts opts')))
|
||||
|
||||
:move-blocks
|
||||
(let [[block-ids target-block-id opts] args
|
||||
blocks (keep #(d/entity @conn %) block-ids)
|
||||
target-block (d/entity @conn target-block-id)]
|
||||
(when (and target-block (seq blocks))
|
||||
(outliner-core/move-blocks! repo conn blocks target-block opts)))
|
||||
(outliner-core/move-blocks! conn blocks target-block opts)))
|
||||
|
||||
:move-blocks-up-down
|
||||
(let [[block-ids up?] args
|
||||
blocks (keep #(d/entity @conn %) block-ids)]
|
||||
(when (seq blocks)
|
||||
(outliner-core/move-blocks-up-down! repo conn blocks up?)))
|
||||
(outliner-core/move-blocks-up-down! conn blocks up?)))
|
||||
|
||||
:indent-outdent-blocks
|
||||
(let [[block-ids indent? opts] args
|
||||
blocks (keep #(d/entity @conn %) block-ids)]
|
||||
(when (seq blocks)
|
||||
(outliner-core/indent-outdent-blocks! repo conn blocks indent? opts)))
|
||||
(outliner-core/indent-outdent-blocks! conn blocks indent? opts)))
|
||||
|
||||
;; properties
|
||||
:upsert-property
|
||||
@@ -260,6 +260,6 @@
|
||||
(apply ldb/transact! conn args)
|
||||
|
||||
(when-let [handler (get @*op-handlers op)]
|
||||
(reset! *result (handler repo conn args))))))
|
||||
(reset! *result (handler conn args))))))
|
||||
|
||||
@*result))
|
||||
|
||||
2
deps/outliner/src/logseq/outliner/tree.cljs
vendored
2
deps/outliner/src/logseq/outliner/tree.cljs
vendored
@@ -6,7 +6,7 @@
|
||||
[logseq.db.common.property-util :as db-property-util]))
|
||||
|
||||
(defprotocol INode
|
||||
(-save [this *txs-state conn repo date-formatter opts])
|
||||
(-save [this *txs-state conn opts])
|
||||
(-del [this *txs-state db]))
|
||||
|
||||
(defn- blocks->vec-tree-aux
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
property-value (:user.property/default (db-test/find-block-by-content @conn "b1"))
|
||||
_ (assert (:db/id property-value))
|
||||
block (db-test/find-block-by-content @conn "b1")]
|
||||
(outliner-core/delete-blocks! nil conn nil [block] {})
|
||||
(outliner-core/delete-blocks! conn [block] {})
|
||||
(is (nil? (db-test/find-block-by-content @conn "b1")))
|
||||
(is (nil? (db-test/find-block-by-content @conn "test block"))))))
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
:block/parent (:db/id page1)}])
|
||||
b3 (db-test/find-block-by-content @conn "b3")
|
||||
b4 (db-test/find-block-by-content @conn "b4")]
|
||||
(outliner-core/delete-blocks! nil conn nil [b3 b4 page2] {})
|
||||
(outliner-core/delete-blocks! conn [b3 b4 page2] {})
|
||||
(is (some? (db-test/find-block-by-content @conn "b3")))
|
||||
(is (some? (db-test/find-block-by-content @conn "b4")))
|
||||
(let [page2' (ldb/get-page @conn "page2")]
|
||||
|
||||
@@ -62,7 +62,5 @@
|
||||
<script defer src="/static/js/tabler-icons-react.min.js"></script>
|
||||
<script defer src="/static/js/tabler.ext.js"></script>
|
||||
<script defer src="/static/js/code-editor.js"></script>
|
||||
<script defer src="/static/js/tldraw.js"></script>
|
||||
<script defer src="/static/js/excalidraw.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -32,11 +32,7 @@
|
||||
[conn ops opts]
|
||||
(when (seq ops)
|
||||
(if util/node-test?
|
||||
(outliner-op/apply-ops! (state/get-current-repo)
|
||||
conn
|
||||
ops
|
||||
(state/get-date-formatter)
|
||||
opts)
|
||||
(outliner-op/apply-ops! conn ops opts)
|
||||
(let [opts' (assoc opts
|
||||
:client-id (:client-id @state/state)
|
||||
:local-tx? true)
|
||||
|
||||
@@ -606,7 +606,7 @@
|
||||
(try
|
||||
(worker-util/profile
|
||||
"apply outliner ops"
|
||||
(outliner-op/apply-ops! repo conn ops (worker-state/get-date-formatter repo) opts))
|
||||
(outliner-op/apply-ops! conn ops opts))
|
||||
(catch :default e
|
||||
(let [data (ex-data e)
|
||||
{:keys [type payload]} (when (map? data) data)]
|
||||
@@ -783,30 +783,29 @@
|
||||
(throw (ex-info "Rename page is a file graph only operation" {})))
|
||||
|
||||
(defn- delete-page!
|
||||
[repo conn page-uuid]
|
||||
[conn page-uuid]
|
||||
(let [error-handler (fn [{:keys [msg]}]
|
||||
(worker-util/post-message :notification
|
||||
[[:div [:p msg]] :error]))]
|
||||
(worker-page/delete! repo conn page-uuid {:error-handler error-handler})))
|
||||
(worker-page/delete! conn page-uuid {:error-handler error-handler})))
|
||||
|
||||
(defn- create-page!
|
||||
[repo conn title options]
|
||||
(let [config (worker-state/get-config repo)]
|
||||
[conn title options]
|
||||
(try
|
||||
(worker-page/create! repo conn config title options)
|
||||
(worker-page/create! conn title options)
|
||||
(catch :default e
|
||||
(js/console.error e)
|
||||
(throw e)))))
|
||||
(throw e))))
|
||||
|
||||
(defn- outliner-register-op-handlers!
|
||||
[]
|
||||
(outliner-op/register-op-handlers!
|
||||
{:create-page (fn [repo conn [title options]]
|
||||
(create-page! repo conn title options))
|
||||
{:create-page (fn [conn [title options]]
|
||||
(create-page! conn title options))
|
||||
:rename-page (fn [& _]
|
||||
(rename-page!))
|
||||
:delete-page (fn [repo conn [page-uuid]]
|
||||
(delete-page! repo conn page-uuid))}))
|
||||
:delete-page (fn [conn [page-uuid]]
|
||||
(delete-page! conn page-uuid))}))
|
||||
|
||||
(defn- on-become-master
|
||||
[repo start-opts]
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
(ns frontend.worker.handler.page
|
||||
"Page operations"
|
||||
(:require [logseq.common.config :as common-config]
|
||||
[logseq.common.util :as common-util]
|
||||
(:require [logseq.common.util :as common-util]
|
||||
[logseq.db :as ldb]
|
||||
[logseq.graph-parser.block :as gp-block]
|
||||
[logseq.outliner.page :as outliner-page]))
|
||||
|
||||
(defn rtc-create-page!
|
||||
[conn config title {:keys [uuid old-db-id]}]
|
||||
[conn title date-formatter {:keys [uuid old-db-id]}]
|
||||
(assert (uuid? uuid) (str "rtc-create-page! `uuid` is not a uuid " uuid))
|
||||
(let [date-formatter (common-config/get-date-formatter config)
|
||||
title (outliner-page/sanitize-title title)
|
||||
(let [title (outliner-page/sanitize-title title)
|
||||
page-name (common-util/page-name-sanity-lc title)
|
||||
page (cond-> (gp-block/page-name->map title @conn true date-formatter
|
||||
{:page-uuid uuid
|
||||
@@ -32,11 +30,11 @@
|
||||
* :persist-op? - when true, add an update-page op
|
||||
* :properties - properties to add to the page
|
||||
TODO: Add other options"
|
||||
[repo conn config title & {:as options}]
|
||||
[conn title & {:as options}]
|
||||
(outliner-page/create! conn title options))
|
||||
|
||||
(defn delete!
|
||||
"Deletes a page. Returns true if able to delete page. If unable to delete,
|
||||
calls error-handler fn and returns false"
|
||||
[repo conn page-uuid & {:as options}]
|
||||
[conn page-uuid & {:as options}]
|
||||
(outliner-page/delete! conn page-uuid options))
|
||||
|
||||
@@ -96,9 +96,8 @@
|
||||
(:block/uuid e)))))))]
|
||||
blocks))))]
|
||||
(when (seq template-blocks)
|
||||
;; FIXME: outliner core apis shouldn't use `repo`
|
||||
(let [result (outliner-core/insert-blocks
|
||||
repo db template-blocks object
|
||||
db template-blocks object
|
||||
{:sibling? false
|
||||
:keep-uuid? journal-template?
|
||||
:outliner-op :insert-template-blocks})]
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
(do (assert (and (pos? (:t apply-ops-resp)) (pos? (:t-query-end apply-ops-resp))) apply-ops-resp)
|
||||
(m/?
|
||||
(r.remote-update/task--apply-remote-update
|
||||
graph-uuid repo conn date-formatter {:type :remote-update :value apply-ops-resp} aes-key add-log-fn))))))
|
||||
graph-uuid repo conn {:type :remote-update :value apply-ops-resp} aes-key add-log-fn))))))
|
||||
|
||||
(defn- new-task--init-request
|
||||
[get-ws-create-task graph-uuid major-schema-version repo conn *last-calibrate-t *server-schema-version add-log-fn]
|
||||
@@ -543,7 +543,7 @@
|
||||
(do (assert (and (pos? (:t r)) (pos? (:t-query-end r))) r)
|
||||
(m/?
|
||||
(r.remote-update/task--apply-remote-update
|
||||
graph-uuid repo conn date-formatter {:type :remote-update :value r} aes-key add-log-fn))
|
||||
graph-uuid repo conn {:type :remote-update :value r} aes-key add-log-fn))
|
||||
(add-log-fn :rtc.log/push-local-update {:remote-t (:t r) :remote-t-query-end (:t-query-end r)})))))))))
|
||||
|
||||
(defn new-task--pull-remote-data
|
||||
|
||||
@@ -267,7 +267,7 @@
|
||||
(:remote-update :remote-asset-block-update)
|
||||
(try
|
||||
(m/? (r.remote-update/task--apply-remote-update
|
||||
graph-uuid repo conn date-formatter event @*aes-key add-log-fn))
|
||||
graph-uuid repo conn event @*aes-key add-log-fn))
|
||||
(catch :default e
|
||||
(if (= :rtc.exception/local-graph-too-old (:type (ex-data e)))
|
||||
(m/? (r.client/new-task--pull-remote-data
|
||||
|
||||
@@ -40,8 +40,7 @@
|
||||
{:persist-op? false
|
||||
:gen-undo-ops? false
|
||||
:outliner-op :delete-blocks
|
||||
:transact-opts {:repo (first args)
|
||||
:conn (second args)}}
|
||||
:transact-opts {:conn (first args)}}
|
||||
(apply outliner-core/delete-blocks! args)))
|
||||
|
||||
(defmethod transact-db! :move-blocks [_ & args]
|
||||
@@ -49,11 +48,10 @@
|
||||
{:persist-op? false
|
||||
:gen-undo-ops? false
|
||||
:outliner-op :move-blocks
|
||||
:transact-opts {:repo (first args)
|
||||
:conn (second args)}}
|
||||
:transact-opts {:conn (first args)}}
|
||||
(apply outliner-core/move-blocks! args)))
|
||||
|
||||
(defmethod transact-db! :update-block-order-directly [_ _repo conn block-uuid block-parent-uuid block-order]
|
||||
(defmethod transact-db! :update-block-order-directly [_ conn block-uuid block-parent-uuid block-order]
|
||||
;; transact :block/parent and :block/order directly,
|
||||
;; check :block/order has any conflicts with other blocks
|
||||
(let [parent-ent (when block-parent-uuid (d/entity @conn [:block/uuid block-parent-uuid]))
|
||||
@@ -98,20 +96,18 @@
|
||||
{:persist-op? true
|
||||
:gen-undo-ops? false
|
||||
:outliner-op :move-blocks
|
||||
:transact-opts {:repo (first args)
|
||||
:conn (second args)}}
|
||||
:transact-opts {:conn (first args)}}
|
||||
(apply outliner-core/move-blocks! args)))
|
||||
|
||||
(defmethod transact-db! :insert-blocks [_ repo conn blocks target opts]
|
||||
(defmethod transact-db! :insert-blocks [_ conn blocks target opts]
|
||||
(outliner-tx/transact!
|
||||
{:persist-op? false
|
||||
:gen-undo-ops? false
|
||||
:outliner-op :insert-blocks
|
||||
:transact-opts {:repo repo
|
||||
:conn conn}}
|
||||
:transact-opts {:conn conn}}
|
||||
(let [opts' (assoc opts :keep-block-order? true)
|
||||
blocks' (map block-reuse-db-id blocks)]
|
||||
(outliner-core/insert-blocks! repo conn blocks' target opts')))
|
||||
(outliner-core/insert-blocks! conn blocks' target opts')))
|
||||
(doseq [block blocks]
|
||||
(assert (some? (d/entity @conn [:block/uuid (:block/uuid block)]))
|
||||
{:msg "insert-block failed"
|
||||
@@ -129,15 +125,6 @@
|
||||
:gen-undo-ops? false
|
||||
:rtc-op? true}))
|
||||
|
||||
(defmethod transact-db! :save-block [_ & args]
|
||||
(outliner-tx/transact!
|
||||
{:persist-op? false
|
||||
:gen-undo-ops? false
|
||||
:outliner-op :save-block
|
||||
:transact-opts {:repo (first args)
|
||||
:conn (second args)}}
|
||||
(apply outliner-core/save-block! args)))
|
||||
|
||||
(defmethod transact-db! :delete-whiteboard-blocks [_ conn block-uuids]
|
||||
(ldb/transact! conn
|
||||
(mapv (fn [block-uuid] [:db/retractEntity [:block/uuid block-uuid]]) block-uuids)
|
||||
@@ -179,7 +166,7 @@
|
||||
:block-uuids-to-remove block-uuid-set}))
|
||||
|
||||
(defn- apply-remote-remove-ops
|
||||
[repo conn date-formatter remove-ops]
|
||||
[conn remove-ops]
|
||||
(let [{whiteboard-block-ops true other-ops false} (group-remote-remove-ops-by-whiteboard-block @conn remove-ops)]
|
||||
(transact-db! :delete-whiteboard-blocks conn (map :block-uuid whiteboard-block-ops))
|
||||
|
||||
@@ -190,15 +177,15 @@
|
||||
(when-let [b (d/entity @conn [:block/uuid block-uuid])]
|
||||
(when-let [target-b
|
||||
(d/entity @conn (:db/id (:block/page (d/entity @conn [:block/uuid block-uuid]))))]
|
||||
(transact-db! :move-blocks&persist-op repo conn [b] target-b {:sibling? false}))))
|
||||
(transact-db! :move-blocks&persist-op conn [b] target-b {:sibling? false}))))
|
||||
(let [deleting-blocks (keep (fn [block-uuid]
|
||||
(d/entity @conn [:block/uuid block-uuid]))
|
||||
block-uuids-to-remove)]
|
||||
(when (seq deleting-blocks)
|
||||
(transact-db! :delete-blocks repo conn date-formatter deleting-blocks {}))))))
|
||||
(transact-db! :delete-blocks conn deleting-blocks {}))))))
|
||||
|
||||
(defn- insert-or-move-block
|
||||
[repo conn block-uuid remote-parents remote-block-order move? op-value]
|
||||
[conn block-uuid remote-parents remote-block-order move? op-value]
|
||||
(when (or (seq remote-parents) remote-block-order) ;at least one of parent|order exists
|
||||
(let [first-remote-parent (first remote-parents)
|
||||
local-parent (when first-remote-parent (d/entity @conn [:block/uuid first-remote-parent]))
|
||||
@@ -208,21 +195,21 @@
|
||||
[false true true]
|
||||
(do
|
||||
(if move?
|
||||
(transact-db! :move-blocks repo conn [(block-reuse-db-id b)] local-parent {:sibling? false})
|
||||
(transact-db! :insert-blocks repo conn
|
||||
(transact-db! :move-blocks conn [(block-reuse-db-id b)] local-parent {:sibling? false})
|
||||
(transact-db! :insert-blocks conn
|
||||
[{:block/uuid block-uuid}]
|
||||
local-parent {:sibling? false :keep-uuid? true}))
|
||||
(transact-db! :update-block-order-directly repo conn block-uuid first-remote-parent remote-block-order))
|
||||
(transact-db! :update-block-order-directly conn block-uuid first-remote-parent remote-block-order))
|
||||
|
||||
[false true false]
|
||||
(if move?
|
||||
(transact-db! :move-blocks repo conn [b] local-parent
|
||||
(transact-db! :move-blocks conn [b] local-parent
|
||||
{:sibling? false})
|
||||
(transact-db! :insert-no-order-blocks conn [[block-uuid first-remote-parent]]))
|
||||
|
||||
[false false true] ;no parent, only update order. e.g. update property's order
|
||||
(when (and (empty? remote-parents) move?)
|
||||
(transact-db! :update-block-order-directly repo conn block-uuid nil remote-block-order))
|
||||
(transact-db! :update-block-order-directly conn block-uuid nil remote-block-order))
|
||||
|
||||
([true false false] [true false true] [true true false] [true true true])
|
||||
(throw (ex-info "Not implemented yet for whiteboard" {:op-value op-value}))
|
||||
@@ -253,9 +240,9 @@
|
||||
(mapv move-ops-map sorted-uuids)))
|
||||
|
||||
(defn- apply-remote-remove-page-ops
|
||||
[repo conn remove-page-ops]
|
||||
[conn remove-page-ops]
|
||||
(doseq [op remove-page-ops]
|
||||
(worker-page/delete! repo conn (:block-uuid op) {:persist-op? false})))
|
||||
(worker-page/delete! conn (:block-uuid op) {:persist-op? false})))
|
||||
|
||||
(defn- get-schema-ref+cardinality
|
||||
[db-schema attr]
|
||||
@@ -375,20 +362,6 @@
|
||||
|
||||
:else nil)))
|
||||
|
||||
(defn- upsert-whiteboard-block
|
||||
[repo conn {:keys [parents properties] :as _op-value}]
|
||||
(let [db @conn
|
||||
first-remote-parent (first parents)]
|
||||
(when-let [local-parent (d/entity db [:block/uuid first-remote-parent])]
|
||||
(let [page-id (:db/id local-parent)
|
||||
properties* (ldb/read-transit-str properties)
|
||||
shape-property-id (db-property-util/get-pid repo :logseq.property.tldraw/shape)
|
||||
shape (and (map? properties*)
|
||||
(get properties* shape-property-id))]
|
||||
(assert (some? page-id) local-parent)
|
||||
(assert (some? shape) properties*)
|
||||
(transact-db! :upsert-whiteboard-block conn [(gp-whiteboard/shape->block repo shape page-id)])))))
|
||||
|
||||
(def ^:private update-op-watched-attrs
|
||||
#{:block/title
|
||||
:block/updated-at
|
||||
@@ -515,45 +488,40 @@
|
||||
{:op-value op-value}))
|
||||
|
||||
(defn- update-block-attrs
|
||||
[repo conn block-uuid {:keys [parents] :as op-value}]
|
||||
[conn block-uuid op-value]
|
||||
(when-let [ent (d/entity @conn [:block/uuid block-uuid])]
|
||||
(when (some (fn [k] (= "block" (namespace k))) (keys op-value)) ; there exists some :block/xxx attrs
|
||||
(let [{update-block-order-tx-data :tx-data op-value :op-value} (update-block-order (:db/id ent) op-value)
|
||||
first-remote-parent (first parents)
|
||||
local-parent (d/entity @conn [:block/uuid first-remote-parent])
|
||||
whiteboard-page-block? (ldb/whiteboard? local-parent)
|
||||
tx-meta {:persist-op? false :gen-undo-ops? false :rtc-op? true}]
|
||||
(if whiteboard-page-block?
|
||||
(upsert-whiteboard-block repo conn op-value)
|
||||
(do (when-let [schema-tx-data (remote-op-value->schema-tx-data block-uuid op-value)]
|
||||
(when-let [schema-tx-data (remote-op-value->schema-tx-data block-uuid op-value)]
|
||||
(ldb/transact! conn schema-tx-data tx-meta))
|
||||
(when-let [tx-data (seq (remote-op-value->tx-data @conn ent (dissoc op-value :client/schema)
|
||||
rtc-const/ignore-attrs-when-syncing))]
|
||||
(ldb/transact! conn (concat tx-data update-block-order-tx-data) tx-meta))))))))
|
||||
(ldb/transact! conn (concat tx-data update-block-order-tx-data) tx-meta))))))
|
||||
|
||||
(defn- apply-remote-update-ops
|
||||
[repo conn update-ops]
|
||||
[conn update-ops]
|
||||
(doseq [{:keys [parents self] block-order :block/order :as op-value} update-ops]
|
||||
(when (and parents block-order)
|
||||
(let [r (check-block-pos @conn self parents block-order)]
|
||||
(case r
|
||||
:not-exist
|
||||
(insert-or-move-block repo conn self parents block-order false op-value)
|
||||
(insert-or-move-block conn self parents block-order false op-value)
|
||||
:wrong-pos
|
||||
(insert-or-move-block repo conn self parents block-order true op-value)
|
||||
(insert-or-move-block conn self parents block-order true op-value)
|
||||
nil)))
|
||||
(update-block-attrs repo conn self op-value)))
|
||||
(update-block-attrs conn self op-value)))
|
||||
|
||||
(defn- apply-remote-move-ops
|
||||
[repo conn sorted-move-ops]
|
||||
[conn sorted-move-ops]
|
||||
(doseq [{:keys [parents self] block-order :block/order :as op-value} sorted-move-ops]
|
||||
(let [r (check-block-pos @conn self parents block-order)]
|
||||
(case r
|
||||
:not-exist
|
||||
(do (insert-or-move-block repo conn self parents block-order false op-value)
|
||||
(update-block-attrs repo conn self op-value))
|
||||
(do (insert-or-move-block conn self parents block-order false op-value)
|
||||
(update-block-attrs conn self op-value))
|
||||
:wrong-pos
|
||||
(insert-or-move-block repo conn self parents block-order true op-value)
|
||||
(insert-or-move-block conn self parents block-order true op-value)
|
||||
;; else
|
||||
nil))))
|
||||
|
||||
@@ -563,7 +531,6 @@
|
||||
|
||||
(defn- apply-remote-update-page-ops
|
||||
[repo conn update-page-ops]
|
||||
(let [config (worker-state/get-config repo)]
|
||||
(doseq [{:keys [self _page-name]
|
||||
title :block/title
|
||||
:as op-value} update-page-ops]
|
||||
@@ -575,15 +542,16 @@
|
||||
(ldb/journal? (d/entity @conn [:block/uuid self])))
|
||||
(let [create-opts {:uuid self
|
||||
:old-db-id (@worker-state/*deleted-block-uuid->db-id self)}
|
||||
[_ page-name page-uuid] (worker-page/rtc-create-page! conn config
|
||||
[_ page-name page-uuid] (worker-page/rtc-create-page! conn
|
||||
(ldb/read-transit-str title)
|
||||
(worker-state/get-date-formatter repo)
|
||||
create-opts)]
|
||||
;; TODO: current page-create fn is buggy, even provide :uuid option, it will create-page with different uuid,
|
||||
;; if there's already existing same name page
|
||||
(assert (= page-uuid self) {:page-name page-name :page-uuid page-uuid :should-be self})
|
||||
(assert (some? (d/entity @conn [:block/uuid page-uuid])) {:page-uuid page-uuid :page-name page-name})))
|
||||
(when (need-update-block-attrs-when-apply-update-page-op? op-value)
|
||||
(update-block-attrs repo conn self op-value))))))
|
||||
(update-block-attrs conn self op-value)))))
|
||||
|
||||
(defn- ensure-refed-blocks-exist
|
||||
"Ensure refed-blocks from remote existing in client"
|
||||
@@ -597,7 +565,7 @@
|
||||
(apply-remote-update-page-ops repo conn [(-> refed-block
|
||||
(assoc :self (:block/uuid refed-block))
|
||||
(dissoc :block/uuid))])
|
||||
(apply-remote-move-ops repo conn [(-> refed-block
|
||||
(apply-remote-move-ops conn [(-> refed-block
|
||||
(assoc :self (:block/uuid refed-block)
|
||||
:parents [(:block/parent refed-block)])
|
||||
(dissoc :block/uuid))])))))))
|
||||
@@ -667,7 +635,7 @@
|
||||
|
||||
(defn task--apply-remote-update
|
||||
"Apply remote-update(`remote-update-event`)"
|
||||
[graph-uuid repo conn date-formatter remote-update-event aes-key add-log-fn]
|
||||
[graph-uuid repo conn remote-update-event aes-key add-log-fn]
|
||||
(m/sp
|
||||
(when (apply-remote-update-check repo remote-update-event add-log-fn)
|
||||
(let [remote-update-data (:value remote-update-event)
|
||||
@@ -697,13 +665,13 @@
|
||||
(fn [temp-conn]
|
||||
(worker-util/profile :ensure-refed-blocks-exist (ensure-refed-blocks-exist repo temp-conn refed-blocks))
|
||||
(worker-util/profile :apply-remote-update-page-ops (apply-remote-update-page-ops repo temp-conn update-page-ops))
|
||||
(worker-util/profile :apply-remote-move-ops (apply-remote-move-ops repo temp-conn sorted-move-ops))
|
||||
(worker-util/profile :apply-remote-update-ops (apply-remote-update-ops repo temp-conn update-ops))
|
||||
(worker-util/profile :apply-remote-remove-page-ops (apply-remote-remove-page-ops repo temp-conn remove-page-ops))))
|
||||
(worker-util/profile :apply-remote-move-ops (apply-remote-move-ops temp-conn sorted-move-ops))
|
||||
(worker-util/profile :apply-remote-update-ops (apply-remote-update-ops temp-conn update-ops))
|
||||
(worker-util/profile :apply-remote-remove-page-ops (apply-remote-remove-page-ops temp-conn remove-page-ops))))
|
||||
|
||||
;; NOTE: we cannot set :persist-op? = true when batch-tx/with-batch-tx-mode (already set to false)
|
||||
;; and there're some transactions in `apply-remote-remove-ops` need to :persist-op?=true
|
||||
(worker-util/profile :apply-remote-remove-ops (apply-remote-remove-ops repo conn date-formatter remove-ops))
|
||||
(worker-util/profile :apply-remote-remove-ops (apply-remote-remove-ops conn remove-ops))
|
||||
|
||||
;; wait all remote-ops transacted into db,
|
||||
;; then start to check any asset-updates in remote
|
||||
|
||||
@@ -202,7 +202,7 @@
|
||||
page-uuid (:block/uuid (db/get-page "foo"))
|
||||
block-uuid (:block/uuid (model/get-block-by-page-name-and-block-route-name repo (str page-uuid) "foo"))]
|
||||
(editor/save-block! repo block-uuid "# bar")
|
||||
(is (= "# bar" (:block/title (model/query-block-by-uuid block-uuid))))
|
||||
(is (= "bar" (:block/title (model/query-block-by-uuid block-uuid))))
|
||||
|
||||
(editor/save-block! repo block-uuid "# bar")
|
||||
(is (= "# bar" (:block/title (model/query-block-by-uuid block-uuid)))))))
|
||||
(is (= "bar" (:block/title (model/query-block-by-uuid block-uuid)))))))
|
||||
|
||||
@@ -144,9 +144,7 @@
|
||||
(transact-tree! tree)
|
||||
(let [block (get-block 6)]
|
||||
(outliner-tx/transact! (transact-opts)
|
||||
(outliner-core/delete-blocks! test-db
|
||||
(db/get-db test-db false)
|
||||
(state/get-date-formatter)
|
||||
(outliner-core/delete-blocks! (db/get-db test-db false)
|
||||
[block] {}))
|
||||
(is (= [3 9] (get-children 2))))))
|
||||
|
||||
@@ -166,8 +164,7 @@
|
||||
(transact-tree! tree)
|
||||
(outliner-tx/transact!
|
||||
(transact-opts)
|
||||
(outliner-core/move-blocks! test-db
|
||||
(db/get-db test-db false)
|
||||
(outliner-core/move-blocks! (db/get-db test-db false)
|
||||
[(get-block 3)] (get-block 14)
|
||||
{:sibling? true}))
|
||||
(is (= [6 9] (get-children 2)))
|
||||
@@ -190,8 +187,7 @@
|
||||
(transact-tree! tree)
|
||||
(outliner-tx/transact!
|
||||
(transact-opts)
|
||||
(outliner-core/move-blocks! test-db
|
||||
(db/get-db test-db false)
|
||||
(outliner-core/move-blocks! (db/get-db test-db false)
|
||||
[(get-block 3)] (get-block 12)
|
||||
{:sibling? false}))
|
||||
(is (= [6 9] (get-children 2)))
|
||||
@@ -204,8 +200,7 @@
|
||||
[5]]]])
|
||||
(outliner-tx/transact!
|
||||
(transact-opts)
|
||||
(outliner-core/move-blocks! test-db
|
||||
(db/get-db test-db false)
|
||||
(outliner-core/move-blocks! (db/get-db test-db false)
|
||||
[(get-block 3)] (get-block 2)
|
||||
{:sibling? true}))
|
||||
(is (= [4] (get-children 2)))
|
||||
@@ -220,8 +215,7 @@
|
||||
[7]]]])
|
||||
(outliner-tx/transact!
|
||||
(transact-opts)
|
||||
(outliner-core/move-blocks! test-db
|
||||
(db/get-db test-db false)
|
||||
(outliner-core/move-blocks! (db/get-db test-db false)
|
||||
[(get-block 3) (get-block 6)] (get-block 2)
|
||||
{:sibling? true}))
|
||||
(is (= [4] (get-children 2)))
|
||||
@@ -237,8 +231,7 @@
|
||||
[8]]]])
|
||||
(outliner-tx/transact!
|
||||
(transact-opts)
|
||||
(outliner-core/move-blocks! test-db
|
||||
(db/get-db test-db false)
|
||||
(outliner-core/move-blocks! (db/get-db test-db false)
|
||||
[(get-block 3) (get-block 5)] (get-block 2)
|
||||
{:sibling? false}))
|
||||
(is (= [3 5 4] (get-children 2)))
|
||||
@@ -260,7 +253,7 @@
|
||||
(transact-tree! tree)
|
||||
(outliner-tx/transact!
|
||||
(transact-opts)
|
||||
(outliner-core/indent-outdent-blocks! test-db (db/get-db test-db false) [(get-block 6) (get-block 9)] true))
|
||||
(outliner-core/indent-outdent-blocks! (db/get-db test-db false) [(get-block 6) (get-block 9)] true))
|
||||
(is (= [4 5 6 9] (get-children 3)))))
|
||||
|
||||
(deftest test-indent-blocks-regression-5604
|
||||
@@ -279,7 +272,7 @@
|
||||
(transact-tree! tree)
|
||||
(outliner-tx/transact!
|
||||
(transact-opts)
|
||||
(outliner-core/indent-outdent-blocks! test-db (db/get-db test-db false) [(get-block 13) (get-block 14) (get-block 15)] false))
|
||||
(outliner-core/indent-outdent-blocks! (db/get-db test-db false) [(get-block 13) (get-block 14) (get-block 15)] false))
|
||||
(is (= [2 12 13 14 15 16] (get-children 22))))
|
||||
(testing "
|
||||
[22 [[2 [[3
|
||||
@@ -296,7 +289,7 @@
|
||||
(transact-tree! tree)
|
||||
(outliner-tx/transact!
|
||||
(transact-opts)
|
||||
(outliner-core/indent-outdent-blocks! test-db (db/get-db test-db false) [(get-block 13) (get-block 14)] false))
|
||||
(outliner-core/indent-outdent-blocks! (db/get-db test-db false) [(get-block 13) (get-block 14)] false))
|
||||
(is (= [2 12 13 14 16] (get-children 22)))))
|
||||
|
||||
(deftest test-outdent-blocks
|
||||
@@ -315,7 +308,7 @@
|
||||
(transact-tree! tree)
|
||||
(outliner-tx/transact!
|
||||
(transact-opts)
|
||||
(outliner-core/indent-outdent-blocks! test-db (db/get-db test-db false) [(get-block 4) (get-block 5)] false))
|
||||
(outliner-core/indent-outdent-blocks! (db/get-db test-db false) [(get-block 4) (get-block 5)] false))
|
||||
(is (= [3 4 5 6 9] (get-children 2)))))
|
||||
|
||||
(deftest test-delete-blocks
|
||||
@@ -334,8 +327,7 @@
|
||||
(transact-tree! tree)
|
||||
(outliner-tx/transact!
|
||||
(transact-opts)
|
||||
(outliner-core/delete-blocks! test-db (db/get-db test-db false)
|
||||
(state/get-date-formatter)
|
||||
(outliner-core/delete-blocks! (db/get-db test-db false)
|
||||
[(get-block 6) (get-block 9)] {}))
|
||||
(is (= [3] (get-children 2)))))
|
||||
|
||||
@@ -355,8 +347,7 @@
|
||||
(transact-tree! tree)
|
||||
(outliner-tx/transact!
|
||||
(transact-opts)
|
||||
(outliner-core/delete-blocks! test-db (db/get-db test-db false)
|
||||
(state/get-date-formatter)
|
||||
(outliner-core/delete-blocks! (db/get-db test-db false)
|
||||
[(get-block 10) (get-block 13)] {}))
|
||||
(is (= [11] (get-children 9)))
|
||||
(is (= [14 15] (get-children 12)))))
|
||||
@@ -376,7 +367,7 @@
|
||||
(transact-tree! tree)
|
||||
(outliner-tx/transact!
|
||||
(transact-opts)
|
||||
(outliner-core/move-blocks-up-down! test-db (db/get-db test-db false) [(get-block 9)] true))
|
||||
(outliner-core/move-blocks-up-down! (db/get-db test-db false) [(get-block 9)] true))
|
||||
(is (= [3 9 6] (get-children 2)))))
|
||||
|
||||
(deftest test-insert-blocks
|
||||
@@ -400,7 +391,6 @@
|
||||
(outliner-tx/transact!
|
||||
(transact-opts)
|
||||
(outliner-core/insert-blocks!
|
||||
test-db
|
||||
(db/get-db test-db false)
|
||||
new-blocks target-block {:sibling? true
|
||||
:keep-uuid? true
|
||||
@@ -426,7 +416,6 @@
|
||||
(outliner-tx/transact!
|
||||
(transact-opts)
|
||||
(outliner-core/insert-blocks!
|
||||
test-db
|
||||
(db/get-db test-db false)
|
||||
[{:block/title "test"
|
||||
:block/parent 1
|
||||
@@ -448,11 +437,10 @@
|
||||
target-block (get-block 2)]
|
||||
(outliner-tx/transact!
|
||||
(transact-opts)
|
||||
(outliner-core/insert-blocks! test-db (db/get-db test-db false) new-blocks target-block {:sibling? false
|
||||
(outliner-core/insert-blocks! (db/get-db test-db false) new-blocks target-block {:sibling? false
|
||||
:keep-uuid? true
|
||||
:replace-empty-target? false})
|
||||
(outliner-core/delete-blocks! test-db (db/get-db test-db false)
|
||||
(state/get-date-formatter)
|
||||
(outliner-core/delete-blocks! (db/get-db test-db false)
|
||||
[(get-block 3)] {}))
|
||||
|
||||
(is (= [4] (get-children 2)))
|
||||
@@ -516,8 +504,7 @@
|
||||
(defn- save-block!
|
||||
[block]
|
||||
(outliner-tx/transact! (transact-opts)
|
||||
(outliner-core/save-block! test-db (db/get-db test-db false)
|
||||
(state/get-date-formatter)
|
||||
(outliner-core/save-block! (db/get-db test-db false)
|
||||
block)))
|
||||
|
||||
(deftest save-test
|
||||
@@ -540,22 +527,10 @@ tags:: tag1, tag2
|
||||
@conn)
|
||||
ffirst)]
|
||||
(is (nil? (:block/tags updated-page))
|
||||
"Page's tags are deleted")
|
||||
(is (= #{"foo" "bar"} (set (map :block/name (:block/alias updated-page))))
|
||||
"Page's aliases remain the same")
|
||||
(is (= {:block/properties {:alias #{"foo" "bar"}}
|
||||
:block/properties-text-values {:alias "foo, bar"}}
|
||||
(select-keys updated-page [:block/properties :block/properties-text-values]))
|
||||
"Page property attributes are correct")
|
||||
(is (= {:block/properties {:alias #{"foo" "bar"}}
|
||||
:block/properties-text-values {:alias "foo, bar"}}
|
||||
(-> (d/q '[:find (pull ?b [*])
|
||||
:where [?b :block/pre-block? true]]
|
||||
@conn)
|
||||
ffirst
|
||||
(select-keys [:block/properties :block/properties-text-values])))
|
||||
"Pre-block property attributes are correct")))
|
||||
"Page's tags are deleted")))
|
||||
|
||||
(comment
|
||||
;; FIXME:
|
||||
(testing "save deletes orphaned pages when a block's refs change"
|
||||
(let [conn (db/get-db test-db false)
|
||||
pages (set (map first (d/q '[:find ?bn :where [?b :block/name ?bn]] @conn)))
|
||||
@@ -568,7 +543,7 @@ tags:: tag1, tag2
|
||||
:block/refs [])))
|
||||
updated-pages (set (map first (d/q '[:find ?bn :where [?b :block/name ?bn]] @conn)))]
|
||||
(is (not (contains? updated-pages "blarg"))
|
||||
"Deleted, orphaned page no longer exists"))))
|
||||
"Deleted, orphaned page no longer exists")))))
|
||||
|
||||
;;; Fuzzy tests
|
||||
|
||||
@@ -600,8 +575,7 @@ tags:: tag1, tag2
|
||||
(defn insert-blocks!
|
||||
[blocks target]
|
||||
(outliner-tx/transact! (transact-opts)
|
||||
(outliner-core/insert-blocks! test-db
|
||||
(db/get-db test-db false)
|
||||
(outliner-core/insert-blocks! (db/get-db test-db false)
|
||||
blocks
|
||||
target
|
||||
{:sibling? (gen/generate gen/boolean)
|
||||
@@ -675,8 +649,7 @@ tags:: tag1, tag2
|
||||
(let [blocks (get-random-blocks)]
|
||||
(when (seq blocks)
|
||||
(outliner-tx/transact! (transact-opts)
|
||||
(outliner-core/delete-blocks! test-db (db/get-db test-db false)
|
||||
(state/get-date-formatter)
|
||||
(outliner-core/delete-blocks! (db/get-db test-db false)
|
||||
blocks {})))))))
|
||||
|
||||
(deftest ^:long random-moves
|
||||
@@ -694,8 +667,7 @@ tags:: tag1, tag2
|
||||
(when (seq blocks)
|
||||
(let [target (get-random-block)]
|
||||
(outliner-tx/transact! (transact-opts)
|
||||
(outliner-core/move-blocks! test-db
|
||||
(db/get-db test-db false)
|
||||
(outliner-core/move-blocks! (db/get-db test-db false)
|
||||
blocks
|
||||
target
|
||||
{:sibling? (gen/generate gen/boolean)}))
|
||||
@@ -716,7 +688,7 @@ tags:: tag1, tag2
|
||||
(let [blocks (get-random-blocks)]
|
||||
(when (seq blocks)
|
||||
(outliner-tx/transact! (transact-opts)
|
||||
(outliner-core/move-blocks-up-down! test-db (db/get-db test-db false) blocks (gen/generate gen/boolean)))
|
||||
(outliner-core/move-blocks-up-down! (db/get-db test-db false) blocks (gen/generate gen/boolean)))
|
||||
(let [total (get-blocks-count)]
|
||||
(is (= total (count @*random-blocks))))))))))
|
||||
|
||||
@@ -735,7 +707,7 @@ tags:: tag1, tag2
|
||||
indent? (gen/generate gen/boolean)]
|
||||
(when (seq blocks)
|
||||
(outliner-tx/transact! (transact-opts)
|
||||
(outliner-core/indent-outdent-blocks! test-db (db/get-db test-db false) blocks indent?))
|
||||
(outliner-core/indent-outdent-blocks! (db/get-db test-db false) blocks indent?))
|
||||
(let [total (get-blocks-count)]
|
||||
(is (= total (count @*random-blocks)))))))))))
|
||||
|
||||
@@ -755,8 +727,7 @@ tags:: tag1, tag2
|
||||
(swap! *random-blocks (fn [old]
|
||||
(set/difference old (set (map :block/uuid blocks)))))
|
||||
(outliner-tx/transact! (transact-opts)
|
||||
(outliner-core/delete-blocks! test-db (db/get-db test-db false)
|
||||
(state/get-date-formatter)
|
||||
(outliner-core/delete-blocks! (db/get-db test-db false)
|
||||
blocks {})))))
|
||||
|
||||
;; move
|
||||
@@ -764,8 +735,7 @@ tags:: tag1, tag2
|
||||
(let [blocks (get-random-blocks)]
|
||||
(when (seq blocks)
|
||||
(outliner-tx/transact! (transact-opts)
|
||||
(outliner-core/move-blocks! test-db
|
||||
(db/get-db test-db false)
|
||||
(outliner-core/move-blocks! (db/get-db test-db false)
|
||||
blocks
|
||||
(get-random-block)
|
||||
{:sibling? (gen/generate gen/boolean)})))))
|
||||
@@ -775,14 +745,14 @@ tags:: tag1, tag2
|
||||
(let [blocks (get-random-blocks)]
|
||||
(when (seq blocks)
|
||||
(outliner-tx/transact! (transact-opts)
|
||||
(outliner-core/move-blocks-up-down! test-db (db/get-db test-db false) blocks (gen/generate gen/boolean))))))
|
||||
(outliner-core/move-blocks-up-down! (db/get-db test-db false) blocks (gen/generate gen/boolean))))))
|
||||
|
||||
;; indent outdent
|
||||
(fn []
|
||||
(let [blocks (get-random-blocks)]
|
||||
(when (seq blocks)
|
||||
(outliner-tx/transact! (transact-opts)
|
||||
(outliner-core/indent-outdent-blocks! test-db (db/get-db test-db false) blocks (gen/generate gen/boolean))))))]]
|
||||
(outliner-core/indent-outdent-blocks! (db/get-db test-db false) blocks (gen/generate gen/boolean))))))]]
|
||||
(dotimes [_i 100]
|
||||
((rand-nth ops)))))
|
||||
|
||||
|
||||
@@ -14,8 +14,7 @@
|
||||
(let [conn (db-test/create-conn-with-blocks
|
||||
[{:page {:block/title "page1"} :blocks [{:block/title "test"}]}])
|
||||
block (db-test/find-block-by-content @conn "test")
|
||||
_ (outliner-core/save-block! "logseq_db_test" conn
|
||||
"MMM do, yyyy"
|
||||
_ (outliner-core/save-block! conn
|
||||
{:block/uuid (:block/uuid block)
|
||||
:block/refs '({:block/name "audio", :block/title "audio", :block/uuid #uuid "6852be3e-6e80-4245-b72c-0d586f1fd007", :block/created-at 1750253118663, :block/updated-at 1750253118663, :block/tags [:logseq.class/Page]}),
|
||||
:block/tags '({:block/name "audio", :block/title "audio", :block/uuid #uuid "6852be3e-6e80-4245-b72c-0d586f1fd007", :block/created-at 1750253118663, :block/updated-at 1750253118663, :block/tags [:logseq.class/Tag]}),
|
||||
@@ -33,8 +32,7 @@
|
||||
block (db-test/find-block-by-content @conn "test")]
|
||||
(doseq [class-ident db-class/page-classes]
|
||||
(let [class (d/entity @conn class-ident)]
|
||||
(outliner-core/save-block! "logseq_db_test" conn
|
||||
"MMM do, yyyy"
|
||||
(outliner-core/save-block! conn
|
||||
{:block/uuid (:block/uuid block)
|
||||
:block/tags [(select-keys class [:block/name :block/title :block/uuid :db/ident])],
|
||||
:block/title (common-util/format "test #[[%s]]" (str (:block/uuid class))),
|
||||
@@ -51,7 +49,7 @@
|
||||
(doseq [class-ident db-class/page-classes]
|
||||
(let [class (d/entity @conn class-ident)
|
||||
new-block-id (random-uuid)
|
||||
_ (outliner-core/insert-blocks! "logseq_db_test" conn
|
||||
_ (outliner-core/insert-blocks! conn
|
||||
[{:block/uuid new-block-id
|
||||
:block/tags [(select-keys class [:block/name :block/title :block/uuid :db/ident])],
|
||||
:block/title (common-util/format "test #[[%s]]" (str (:block/uuid class))),
|
||||
|
||||
@@ -249,6 +249,5 @@ This can be called in synchronous contexts as no async fns should be invoked"
|
||||
[title & {:as opts}]
|
||||
(let [repo (state/get-current-repo)
|
||||
conn (db/get-db repo false)
|
||||
config (state/get-config repo)
|
||||
[page-name _page-uuid] (worker-page/create! repo conn config title opts)]
|
||||
[page-name _page-uuid] (worker-page/create! conn title opts)]
|
||||
page-name))
|
||||
|
||||
@@ -128,9 +128,7 @@
|
||||
conn (conn/get-db repo false)
|
||||
[page-uuid block-uuid1 block-uuid2] (repeatedly random-uuid)]
|
||||
(testing "add page"
|
||||
(worker-page/create! repo conn (worker-state/get-config repo)
|
||||
"TEST-PAGE"
|
||||
{:uuid page-uuid})
|
||||
(worker-page/create! conn "TEST-PAGE" {:uuid page-uuid})
|
||||
(is (some? (d/pull @conn '[*] [:block/uuid page-uuid])))
|
||||
(is (= {page-uuid #{:update-page :update}}
|
||||
(ops-coll=>block-uuid->op-types (client-op/get&remove-all-block-ops repo)))))
|
||||
@@ -138,7 +136,7 @@
|
||||
(let [target-entity (d/entity @conn [:block/uuid page-uuid])]
|
||||
(batch-tx/with-batch-tx-mode conn
|
||||
{:persist-op? true}
|
||||
(outliner-core/insert-blocks! repo conn [{:block/uuid block-uuid1
|
||||
(outliner-core/insert-blocks! conn [{:block/uuid block-uuid1
|
||||
:block/title "block1"}
|
||||
{:block/uuid block-uuid2
|
||||
:block/title "block2"}]
|
||||
@@ -152,7 +150,7 @@
|
||||
(testing "delete a block"
|
||||
(batch-tx/with-batch-tx-mode conn
|
||||
{:persist-op? true}
|
||||
(outliner-core/delete-blocks! repo conn nil [(d/entity @conn [:block/uuid block-uuid1])] {}))
|
||||
(outliner-core/delete-blocks! conn [(d/entity @conn [:block/uuid block-uuid1])] {}))
|
||||
|
||||
(is (=
|
||||
{block-uuid1 #{:remove}}
|
||||
|
||||
@@ -157,12 +157,12 @@
|
||||
r)))))
|
||||
|
||||
(defn- apply-move-ops!
|
||||
[repo conn move-ops]
|
||||
[conn move-ops]
|
||||
(ldb/transact-with-temp-conn!
|
||||
conn
|
||||
{}
|
||||
(fn [temp-conn]
|
||||
(#'r.remote/apply-remote-move-ops repo temp-conn move-ops))))
|
||||
(#'r.remote/apply-remote-move-ops temp-conn move-ops))))
|
||||
|
||||
(deftest apply-remote-move-ops-test
|
||||
(let [repo (state/get-current-repo)
|
||||
@@ -178,7 +178,6 @@
|
||||
(outliner-tx/transact!
|
||||
opts
|
||||
(outliner-core/insert-blocks!
|
||||
repo
|
||||
conn
|
||||
[{:block/uuid uuid1-client
|
||||
:block/title "uuid1-client"
|
||||
@@ -208,7 +207,7 @@
|
||||
(#'r.remote/affected-blocks->diff-type-ops
|
||||
repo (:affected-blocks data-from-ws))))]
|
||||
(is (rtc-schema/data-from-ws-validator data-from-ws) data-from-ws)
|
||||
(apply-move-ops! repo conn move-ops)
|
||||
(apply-move-ops! conn move-ops)
|
||||
(let [page-blocks (ldb/get-page-blocks @conn (:db/id (ldb/get-page @conn page-name)) {})]
|
||||
(is (= #{uuid1-remote uuid1-client uuid2-client} (set (map :block/uuid page-blocks)))
|
||||
[uuid1-remote uuid1-client uuid2-client])
|
||||
@@ -238,7 +237,7 @@
|
||||
(#'r.remote/affected-blocks->diff-type-ops
|
||||
repo (:affected-blocks data-from-ws))))]
|
||||
(is (rtc-schema/data-from-ws-validator data-from-ws))
|
||||
(apply-move-ops! repo conn move-ops)
|
||||
(apply-move-ops! conn move-ops)
|
||||
(let [page-blocks (ldb/get-page-blocks @conn (:db/id (ldb/get-page @conn page-name)) {})]
|
||||
(is (= #{uuid1-remote uuid2-remote uuid1-client uuid2-client} (set (map :block/uuid page-blocks))))
|
||||
(is (= ["a0" "a1"]
|
||||
@@ -251,7 +250,6 @@
|
||||
opts {:persist-op? false
|
||||
:transact-opts {:repo repo
|
||||
:conn conn}}
|
||||
date-formatter (common-config/get-date-formatter (worker-state/get-config repo))
|
||||
page-name "apply-remote-remove-ops-test"
|
||||
[page-uuid
|
||||
uuid1-client uuid2-client
|
||||
@@ -260,7 +258,6 @@
|
||||
(outliner-tx/transact!
|
||||
opts
|
||||
(outliner-core/insert-blocks!
|
||||
repo
|
||||
conn
|
||||
[{:block/uuid uuid1-client :block/title "uuid1-client"
|
||||
:block/left [:block/uuid page-uuid]
|
||||
@@ -280,7 +277,7 @@
|
||||
(:remove-ops-map
|
||||
(#'r.remote/affected-blocks->diff-type-ops repo (:affected-blocks data-from-ws))))]
|
||||
(is (rtc-schema/data-from-ws-validator data-from-ws))
|
||||
(#'r.remote/apply-remote-remove-ops repo conn date-formatter remove-ops)
|
||||
(#'r.remote/apply-remote-remove-ops conn remove-ops)
|
||||
(let [page-blocks (ldb/get-page-blocks @conn (:db/id (ldb/get-page @conn page-name)) {})]
|
||||
(is (= #{uuid1-client uuid2-client} (set (map :block/uuid page-blocks)))))))
|
||||
(testing "apply-remote-remove-ops-test2"
|
||||
@@ -292,7 +289,7 @@
|
||||
(:remove-ops-map
|
||||
(#'r.remote/affected-blocks->diff-type-ops repo (:affected-blocks data-from-ws))))]
|
||||
(is (rtc-schema/data-from-ws-validator data-from-ws))
|
||||
(#'r.remote/apply-remote-remove-ops repo conn date-formatter remove-ops)
|
||||
(#'r.remote/apply-remote-remove-ops conn remove-ops)
|
||||
(let [page-blocks (ldb/get-page-blocks @conn (:db/id (ldb/get-page @conn page-name)) {})]
|
||||
(is (= #{uuid2-client} (set (map :block/uuid page-blocks)))))))))
|
||||
|
||||
@@ -328,7 +325,7 @@ result:
|
||||
;; - 1
|
||||
;; - 2
|
||||
;; - 3
|
||||
repo conn
|
||||
conn
|
||||
[{:block/uuid uuid1 :block/title "1"
|
||||
:block/order "a0"
|
||||
:block/parent [:block/uuid page-uuid]}
|
||||
@@ -349,7 +346,7 @@ result:
|
||||
(:remove-ops-map
|
||||
(#'r.remote/affected-blocks->diff-type-ops repo (:affected-blocks data-from-ws))))]
|
||||
(is (rtc-schema/data-from-ws-validator data-from-ws))
|
||||
(#'r.remote/apply-remote-remove-ops repo conn date-formatter remove-ops)
|
||||
(#'r.remote/apply-remote-remove-ops conn remove-ops)
|
||||
(let [page-blocks (ldb/get-page-blocks @conn (:db/id (ldb/get-page @conn page-name)))]
|
||||
(is (= [uuid3 uuid1] (map :block/uuid (sort-by :block/order page-blocks)))))))))
|
||||
|
||||
@@ -402,7 +399,7 @@ result:
|
||||
(:remove-page-ops-map
|
||||
(#'r.remote/affected-blocks->diff-type-ops repo (:affected-blocks data-from-ws))))]
|
||||
(is (rtc-schema/data-from-ws-validator data-from-ws))
|
||||
(#'r.remote/apply-remote-remove-page-ops repo conn remove-page-ops)
|
||||
(#'r.remote/apply-remote-remove-page-ops conn remove-page-ops)
|
||||
(is (nil? (d/entity @conn [:block/uuid page1-uuid])))))))
|
||||
|
||||
;; TODO: add back once page merge get supported
|
||||
|
||||
29
ssl/ca.pem
29
ssl/ca.pem
@@ -1,29 +0,0 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIE+zCCA2OgAwIBAgIQTfWeF1QJkSfpzuDXGxklNTANBgkqhkiG9w0BAQsFADCB
|
||||
lTEeMBwGA1UEChMVbWtjZXJ0IGRldmVsb3BtZW50IENBMTUwMwYDVQQLDCxjaGFy
|
||||
bGllQENoYXJsaWVzLU1hY0Jvb2stUHJvLmxvY2FsIChDaGFybGllKTE8MDoGA1UE
|
||||
AwwzbWtjZXJ0IGNoYXJsaWVAQ2hhcmxpZXMtTWFjQm9vay1Qcm8ubG9jYWwgKENo
|
||||
YXJsaWUpMB4XDTI1MDQwODAzMDQwM1oXDTM1MDQwODAzMDQwM1owgZUxHjAcBgNV
|
||||
BAoTFW1rY2VydCBkZXZlbG9wbWVudCBDQTE1MDMGA1UECwwsY2hhcmxpZUBDaGFy
|
||||
bGllcy1NYWNCb29rLVByby5sb2NhbCAoQ2hhcmxpZSkxPDA6BgNVBAMMM21rY2Vy
|
||||
dCBjaGFybGllQENoYXJsaWVzLU1hY0Jvb2stUHJvLmxvY2FsIChDaGFybGllKTCC
|
||||
AaIwDQYJKoZIhvcNAQEBBQADggGPADCCAYoCggGBALtxg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mEK
|
||||
JkXj+s85cykTNBOUY9a+bDr2qrynCsiaSXkGtyWSgdbAR7HHSOWIZX216aaTKdmm
|
||||
gt5r1+ZK0qcYx6SR8qvdJN+7WY+apQA1Z9kV3fMrHVnCxR8zp8Vjmk0R1TsV6uxi
|
||||
VGo45tVFDtL0EajZ7yxif/v29fs7/VtV8tXPytMzkQ==
|
||||
-----END CERTIFICATE-----
|
||||
BIN
ssl/keystore.jks
BIN
ssl/keystore.jks
Binary file not shown.
@@ -1,28 +0,0 @@
|
||||
-----BEGIN PRIVATE KEY-----
|
||||
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDUCoY5g5MwfD23
|
||||
vtb9nk3dOnZkRMCM9dIC7IN01U2T1S74iKYPO0NwrpoTNvKDY/Fkon2kv6CSUTk1
|
||||
BSR0ewY4k/U1/PgiTM2738c4YESQA0PNd4l6Vj4jjGpTPCqR+nrzdWgNGxyEzw5l
|
||||
/4SYO8MGahYglPdWqI4K7tvnesZ1ZKlLRrVfiKs3oLTK2GTrQxEUGiI7jwcNyKSZ
|
||||
z7biTSoZseJea+yh/E52FKQU91v/PdI+CXD9Y3zDmdfpqHYrIM18wOGVBlJoR3Fu
|
||||
RKMAh/TxmNKJrlTiYcNfP4VJwOpk4JukNJjOoMBzlm5x1YFKi2UMhItuHKmIMFHy
|
||||
RGSCktalAgMBAAECggEBAMqv/LpBkZNJT92yqOPqTNfqKH2UUtLrsAJnfwlRVES6
|
||||
BZpBVSs+JSszW8h+P7dk87yUrrGrE5yJ07tg3QYTC1FN7Znb5H01GXw7Xr3/F8rp
|
||||
tAhV+a5dfiyQ7pn961t7KchLNFlCzzIMkuDhLSgwCC67fcdLXlsR6CV/SemtrMNM
|
||||
5J65BDwZDcMNv7u6iP3DHf3Brl+ywXd3TAZzO+gWd4IUtW3z38yzPX7T5jQb7Nvk
|
||||
C4VOipDri5EtGh7aSFj1ieUXHYBzLSvBAfsWCgmFPDJlVaY67cBOBHGoJ/s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