This commit is contained in:
Liang Ding 2022-12-29 22:00:07 +08:00
parent b999d293d5
commit 192679eedd
No known key found for this signature in database
GPG key ID: 136F30F901A2231D

View file

@ -41,6 +41,7 @@ var Decks = map[string]*riff.Deck{}
var deckLock = sync.Mutex{}
func GetFlashcards(deckID string, page int) (blockIDs []string, total, pageCount int) {
blockIDs = []string{}
deck := Decks[deckID]
if nil == deck {
return
@ -64,6 +65,9 @@ func GetFlashcards(deckID string, page int) (blockIDs []string, total, pageCount
blockIDs = allBlockIDs[start:end]
total = len(allBlockIDs)
pageCount = int(math.Ceil(float64(total) / float64(pageSize)))
if 1 > len(blockIDs) {
blockIDs = []string{}
}
return
}