🎨 闪卡管理排序

This commit is contained in:
Liang Ding 2023-03-24 11:26:25 +08:00
parent 71a6158f61
commit 8758110a67
No known key found for this signature in database
GPG key ID: 136F30F901A2231D

View file

@ -137,6 +137,8 @@ func GetFlashcards(deckID string, page int) (blocks []*Block, total, pageCount i
}
func getCardsBlocks(cards []riff.Card, page int) (blocks []*Block, total, pageCount int) {
sort.Slice(cards, func(i, j int) bool { return cards[i].BlockID() < cards[j].BlockID() })
const pageSize = 20
total = len(cards)
pageCount = int(math.Ceil(float64(total) / float64(pageSize)))