enhance(srs): move db-based fns to fsrs

This commit is contained in:
rcmerci
2024-09-23 23:02:45 +08:00
parent a1eab5c500
commit 6ab025c3f1
4 changed files with 83 additions and 91 deletions

View File

@@ -7,9 +7,15 @@
[frontend.db :as db]
[frontend.db.async :as db-async]
[frontend.extensions.srs :as srs]
[frontend.handler.block :as block-handler]
[frontend.handler.db-based.property :as db-property-handler]
[frontend.handler.property :as property-handler]
[frontend.modules.shortcut.core :as shortcut]
[frontend.state :as state]
[frontend.ui :as ui]
[frontend.util :as util]
[logseq.db :as ldb]
[logseq.shui.ui :as shui]
[missionary.core :as m]
[open-spaced-repetition.cljc-fsrs.core :as fsrs.core]
[rum.core :as rum]
@@ -252,3 +258,23 @@
(let [canceler (c.m/run-task new-task--update-due-cards-count :update-due-cards-count)]
(reset! *last-update-due-cards-count-canceler canceler)
nil))
(defn- get-operating-blocks
[block-ids]
(some->> block-ids
(map (fn [id] (db/entity [:block/uuid id])))
(seq)
block-handler/get-top-level-blocks
(remove ldb/property?)))
(defn batch-make-cards!
([] (batch-make-cards! (state/get-selection-block-ids)))
([block-ids]
(let [repo (state/get-current-repo)
blocks (get-operating-blocks block-ids)]
(when-let [block-ids (not-empty (map :block/uuid blocks))]
(property-handler/batch-set-block-property!
repo
block-ids
:block/tags
(:db/id (db/entity :logseq.class/Card)))))))