From e87ab009695408d6685ec12f4012c0fa1434846e Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Thu, 22 Dec 2022 15:50:20 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E6=94=AF=E6=8C=81=E9=97=B4=E9=9A=94?= =?UTF-8?q?=E5=A4=8D=E4=B9=A0=20https://github.com/siyuan-note/siyuan/issu?= =?UTF-8?q?es/6710?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/model/flashcard.go | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/kernel/model/flashcard.go b/kernel/model/flashcard.go index 6d908cd1a..1dc93aaa3 100644 --- a/kernel/model/flashcard.go +++ b/kernel/model/flashcard.go @@ -68,7 +68,12 @@ func ReviewFlashcard(deckID string, blockID string, rating riff.Rating) (err err return } -func GetDueFlashcards(deckID string) (ret []string, err error) { +type Flashcard struct { + DeckID string `json:"deckID"` + BlockID string `json:"blockID"` +} + +func GetDueFlashcards(deckID string) (ret []*Flashcard, err error) { if "" == deckID { return getAllDueFlashcards() } @@ -84,15 +89,18 @@ func GetDueFlashcards(deckID string) (ret []string, err error) { if nil != getErr { continue } - ret = append(ret, blockID) + ret = append(ret, &Flashcard{ + DeckID: deckID, + BlockID: blockID, + }) } if 1 > len(ret) { - ret = []string{} + ret = []*Flashcard{} } return } -func getAllDueFlashcards() (ret []string, err error) { +func getAllDueFlashcards() (ret []*Flashcard, err error) { blockIDs := map[string]bool{} for _, deck := range Decks { cards := deck.Dues() @@ -107,12 +115,15 @@ func getAllDueFlashcards() (ret []string, err error) { continue } - ret = append(ret, blockID) + ret = append(ret, &Flashcard{ + DeckID: deck.ID, + BlockID: blockID, + }) blockIDs[blockID] = true } } if 1 > len(ret) { - ret = []string{} + ret = []*Flashcard{} } return }