🎨 闪卡管理排序

This commit is contained in:
Liang Ding 2023-03-24 11:26:25 +08:00
parent fbe7400893
commit 68b4ee8600
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)))