|
@@ -148,6 +148,12 @@ func GetNotebookFlashcards(boxID string, page int) (blocks []*Block, total, page
|
|
|
|
|
|
func GetTreeFlashcards(rootID string, page int) (blocks []*Block, total, pageCount int) {
|
|
|
blocks = []*Block{}
|
|
|
+ cards := getTreeSubTreeFlashcards(rootID)
|
|
|
+ blocks, total, pageCount = getCardsBlocks(cards, page)
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+func getTreeSubTreeFlashcards(rootID string) (ret []riff.Card) {
|
|
|
deck := Decks[builtinDeckID]
|
|
|
if nil == deck {
|
|
|
return
|
|
@@ -162,9 +168,26 @@ func GetTreeFlashcards(rootID string, page int) (blocks []*Block, total, pageCou
|
|
|
}
|
|
|
}
|
|
|
allBlockIDs = gulu.Str.RemoveDuplicatedElem(allBlockIDs)
|
|
|
- cards := deck.GetCardsByBlockIDs(allBlockIDs)
|
|
|
+ ret = deck.GetCardsByBlockIDs(allBlockIDs)
|
|
|
+ return
|
|
|
+}
|
|
|
|
|
|
- blocks, total, pageCount = getCardsBlocks(cards, page)
|
|
|
+func getTreeFlashcards(rootID string) (ret []riff.Card) {
|
|
|
+ deck := Decks[builtinDeckID]
|
|
|
+ if nil == deck {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ var allBlockIDs []string
|
|
|
+ deckBlockIDs := deck.GetBlockIDs()
|
|
|
+ treeBlockIDsMap, _ := getTreeBlocks(rootID)
|
|
|
+ for _, blockID := range deckBlockIDs {
|
|
|
+ if treeBlockIDsMap[blockID] {
|
|
|
+ allBlockIDs = append(allBlockIDs, blockID)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ allBlockIDs = gulu.Str.RemoveDuplicatedElem(allBlockIDs)
|
|
|
+ ret = deck.GetCardsByBlockIDs(allBlockIDs)
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -420,6 +443,16 @@ func getTreeSubTreeChildBlocks(rootID string) (treeBlockIDsMap map[string]bool,
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+func getTreeBlocks(rootID string) (treeBlockIDsMap map[string]bool, treeBlockIDs []string) {
|
|
|
+ treeBlockIDsMap = map[string]bool{}
|
|
|
+ bts := treenode.GetBlockTreesByRootID(rootID)
|
|
|
+ for _, bt := range bts {
|
|
|
+ treeBlockIDsMap[bt.ID] = true
|
|
|
+ treeBlockIDs = append(treeBlockIDs, bt.ID)
|
|
|
+ }
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
func getBoxBlocks(boxID string) (blockIDsMap map[string]bool, blockIDs []string) {
|
|
|
blockIDsMap = map[string]bool{}
|
|
|
bts := treenode.GetBlockTreesByBoxID(boxID)
|