mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-05 16:28:49 +01:00
🎨 Spaced repetition interface supports review by document selection https://github.com/siyuan-note/siyuan/issues/7954
This commit is contained in:
parent
0ebdd49f8a
commit
66bd5e91a5
7 changed files with 112 additions and 38 deletions
|
|
@ -47,14 +47,24 @@ func GetFlashcardNotebooks() (ret []*Box) {
|
|||
|
||||
boxes := Conf.GetOpenedBoxes()
|
||||
for _, box := range boxes {
|
||||
if isNotebookContainFlashcard(box.ID, deckBlockIDs) {
|
||||
if isBoxContainFlashcard(box.ID, deckBlockIDs) {
|
||||
ret = append(ret, box)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func isNotebookContainFlashcard(boxID string, deckBlockIDs []string) (ret bool) {
|
||||
func isTreeContainFlashcard(rootID string, deckBlockIDs []string) (ret bool) {
|
||||
blockIDs := getTreeSubTreeChildBlocks(rootID)
|
||||
for _, blockID := range deckBlockIDs {
|
||||
if gulu.Str.Contains(blockID, blockIDs) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func isBoxContainFlashcard(boxID string, deckBlockIDs []string) (ret bool) {
|
||||
entries, err := os.ReadDir(filepath.Join(util.DataDir, boxID))
|
||||
if nil != err {
|
||||
logging.LogErrorf("read dir failed: %s", err)
|
||||
|
|
@ -71,11 +81,8 @@ func isNotebookContainFlashcard(boxID string, deckBlockIDs []string) (ret bool)
|
|||
}
|
||||
|
||||
rootID := strings.TrimSuffix(entry.Name(), ".sy")
|
||||
blockIDs := getTreeSubTreeChildBlocks(rootID)
|
||||
for _, blockID := range deckBlockIDs {
|
||||
if gulu.Str.Contains(blockID, blockIDs) {
|
||||
return true
|
||||
}
|
||||
if isTreeContainFlashcard(rootID, deckBlockIDs) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue