From f0cce9f6d19f252b46afd10880863621902c25a0 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Mon, 13 Mar 2023 11:41:37 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20=E9=97=AA=E5=8D=A1=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=88=86=E9=A1=B5=E5=A4=B1=E6=95=88=20Fix=20https://github.com?= =?UTF-8?q?/siyuan-note/siyuan/issues/7638?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/model/flashcard.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/kernel/model/flashcard.go b/kernel/model/flashcard.go index 7ee0d8dd7..0a557c165 100644 --- a/kernel/model/flashcard.go +++ b/kernel/model/flashcard.go @@ -136,6 +136,8 @@ func GetFlashcards(deckID string, page int) (blocks []*Block, total, pageCount i func getCardsBlocks(cards []riff.Card, page int) (blocks []*Block, total, pageCount int) { const pageSize = 20 + total = len(cards) + pageCount = int(math.Ceil(float64(total) / float64(pageSize))) start := (page - 1) * pageSize end := page * pageSize if start > len(cards) { @@ -144,10 +146,9 @@ func getCardsBlocks(cards []riff.Card, page int) (blocks []*Block, total, pageCo if end > len(cards) { end = len(cards) } - cardIDs := cards[start:end] - total = len(cards) - pageCount = int(math.Ceil(float64(total) / float64(pageSize))) - if 1 > len(cardIDs) { + + cards = cards[start:end] + if 1 > len(cards) { blocks = []*Block{} return }