refactor: remove db/get-paginated-blocks

This commit is contained in:
Tienson Qin
2023-06-20 14:06:42 +08:00
parent c238a7b08a
commit 029b196432
8 changed files with 33 additions and 211 deletions

View File

@@ -48,31 +48,6 @@
[block]
(get-timestamp block "Deadline"))
(defn load-more!
[db-id start-id]
(let [repo (state/get-current-repo)
db (db/get-db repo)
block (db/entity repo db-id)
block? (not (:block/name block))
k (if block?
:frontend.db.react/block-and-children
:frontend.db.react/page-blocks)
query-k [repo k db-id]
option (cond-> {:limit db-model/step-loading-blocks}
block?
(assoc :scoped-block-id db-id))
query-result (react/get-query-cached-result query-k)
start-id' (or
(when query-result (:db/id (last @query-result)))
start-id)
more-data (db-model/get-paginated-blocks-no-cache db start-id' option)]
(react/swap-new-result! query-k
(fn [[entities _tx-data]]
(let [entities' (->> (concat entities more-data)
(util/distinct-by :block/uuid))
tx-data' (mapv (juxt :block/parent :block/left :block/collapsed?) more-data)]
[entities' tx-data'])))))
(defn indentable?
[{:block/keys [parent left]}]
(when parent