mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-31 22:08:48 +01:00
🎨 Show count in spaced repetition tree filter floating window https://github.com/siyuan-note/siyuan/issues/8202
This commit is contained in:
parent
d7fcf3cbe1
commit
1c68ce46f9
2 changed files with 19 additions and 20 deletions
|
|
@ -43,9 +43,10 @@ func GetFlashcardNotebooks() (ret []*Box) {
|
|||
return
|
||||
}
|
||||
|
||||
deckBlockIDs := deck.GetBlockIDs()
|
||||
boxes := Conf.GetOpenedBoxes()
|
||||
for _, box := range boxes {
|
||||
newFlashcardCount, dueFlashcardCount, flashcardCount := countBoxFlashcard(box.ID)
|
||||
newFlashcardCount, dueFlashcardCount, flashcardCount := countBoxFlashcard(box.ID, deck, deckBlockIDs)
|
||||
if 0 < flashcardCount {
|
||||
box.NewFlashcardCount = newFlashcardCount
|
||||
box.DueFlashcardCount = dueFlashcardCount
|
||||
|
|
@ -56,13 +57,7 @@ func GetFlashcardNotebooks() (ret []*Box) {
|
|||
return
|
||||
}
|
||||
|
||||
func countTreeFlashcard(rootID string) (newFlashcardCount, dueFlashcardCount, flashcardCount int) {
|
||||
deck := Decks[builtinDeckID]
|
||||
if nil == deck {
|
||||
return
|
||||
}
|
||||
|
||||
deckBlockIDs := deck.GetBlockIDs()
|
||||
func countTreeFlashcard(rootID string, deck *riff.Deck, deckBlockIDs []string) (newFlashcardCount, dueFlashcardCount, flashcardCount int) {
|
||||
blockIDs := getTreeSubTreeChildBlocks(rootID)
|
||||
for _, blockID := range deckBlockIDs {
|
||||
if gulu.Str.Contains(blockID, blockIDs) {
|
||||
|
|
@ -80,12 +75,7 @@ func countTreeFlashcard(rootID string) (newFlashcardCount, dueFlashcardCount, fl
|
|||
return
|
||||
}
|
||||
|
||||
func countBoxFlashcard(boxID string) (newFlashcardCount, dueFlashcardCount, flashcardCount int) {
|
||||
deck := Decks[builtinDeckID]
|
||||
if nil == deck {
|
||||
return
|
||||
}
|
||||
|
||||
func countBoxFlashcard(boxID string, deck *riff.Deck, deckBlockIDs []string) (newFlashcardCount, dueFlashcardCount, flashcardCount int) {
|
||||
entries, err := os.ReadDir(filepath.Join(util.DataDir, boxID))
|
||||
if nil != err {
|
||||
logging.LogErrorf("read dir failed: %s", err)
|
||||
|
|
@ -102,7 +92,7 @@ func countBoxFlashcard(boxID string) (newFlashcardCount, dueFlashcardCount, flas
|
|||
}
|
||||
|
||||
rootID := strings.TrimSuffix(entry.Name(), ".sy")
|
||||
treeNewFlashcardCount, treeDueFlashcardCount, treeFlashcardCount := countTreeFlashcard(rootID)
|
||||
treeNewFlashcardCount, treeDueFlashcardCount, treeFlashcardCount := countTreeFlashcard(rootID, deck, deckBlockIDs)
|
||||
flashcardCount += treeFlashcardCount
|
||||
newFlashcardCount += treeNewFlashcardCount
|
||||
dueFlashcardCount += treeDueFlashcardCount
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue