Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: Sort by Due asc on the flashcard management UI https://github.com/siyuan-note/siyuan/pull/9673#issuecomment-1823003087

Daniel183621ea007b
diff --git a/kernel/model/flashcard.go b/kernel/model/flashcard.go
index 9157571e37..1d041c6098 100644
--- a/kernel/model/flashcard.go
+++ b/kernel/model/flashcard.go
@@ -309,7 +309,12 @@ func GetDeckFlashcards(deckID string, page int) (blocks []*Block, total, pageCou
}
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() })
+ // sort by due date asc https://github.com/siyuan-note/siyuan/pull/9673
+ sort.Slice(cards, func(i, j int) bool {
+ due1 := cards[i].(*riff.FSRSCard).C.Due
+ due2 := cards[j].(*riff.FSRSCard).C.Due
+ return due1.Before(due2)
+ })
const pageSize = 20
total = len(cards)
@@ -329,13 +334,6 @@ func getCardsBlocks(cards []riff.Card, page int) (blocks []*Block, total, pageCo
return
}
- // sort by due date asc https://github.com/siyuan-note/siyuan/pull/9673
- sort.Slice(cards, func(i, j int) bool {
- due1 := cards[i].(*riff.FSRSCard).C.Due
- due2 := cards[j].(*riff.FSRSCard).C.Due
- return due1.Before(due2)
- })
-
var blockIDs []string
for _, card := range cards {
blockIDs = append(blockIDs, card.BlockID())