From 4782573544453e9b60baf236e465340ce9eedc93 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Wed, 15 Feb 2023 09:54:17 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E9=97=AA=E5=8D=A1=E7=95=8C=E9=9D=A2?= =?UTF-8?q?=E5=A4=A7=E5=B0=8F=E8=B0=83=E6=95=B4=E5=8F=8A=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E9=A2=84=E8=A7=88=20https://github.com/siyuan-note/siyuan/issu?= =?UTF-8?q?es/7368?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/model/flashcard.go | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/kernel/model/flashcard.go b/kernel/model/flashcard.go index a2cbc7497..72692c3a9 100644 --- a/kernel/model/flashcard.go +++ b/kernel/model/flashcard.go @@ -43,18 +43,26 @@ var deckLock = sync.Mutex{} func GetFlashcards(deckID string, page int) (blocks []*Block, total, pageCount int) { blocks = []*Block{} - deck := Decks[deckID] - if nil == deck { - return - } - - const pageSize = 20 var allBlockIDs []string - for bID, _ := range deck.BlockCard { - allBlockIDs = append(allBlockIDs, bID) - } - sort.Strings(allBlockIDs) + const pageSize = 20 + if "" == deckID { + for _, deck := range Decks { + for bID, _ := range deck.BlockCard { + allBlockIDs = append(allBlockIDs, bID) + } + } + } else { + deck := Decks[deckID] + if nil == deck { + return + } + for bID, _ := range deck.BlockCard { + allBlockIDs = append(allBlockIDs, bID) + } + } + + sort.Strings(allBlockIDs) start := (page - 1) * pageSize end := page * pageSize if start > len(allBlockIDs) {