mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-10 17:24:21 +01:00
🎨 Add internal kernel API /api/riff/batchSetRiffCardsDueTime https://github.com/siyuan-note/siyuan/issues/10423
This commit is contained in:
parent
3ec2ff243f
commit
285eb12b48
5 changed files with 78 additions and 12 deletions
|
|
@ -38,6 +38,46 @@ import (
|
|||
"github.com/siyuan-note/siyuan/kernel/util"
|
||||
)
|
||||
|
||||
type SetFlashcardDueTime struct {
|
||||
ID string `json:"id"` // 卡片 ID
|
||||
Due string `json:"due"` // 下次复习时间,格式为 YYYYMMDDHHmmss
|
||||
}
|
||||
|
||||
func SetFlashcardsDueTime(cardDues []*SetFlashcardDueTime) (err error) {
|
||||
// Add internal kernel API `/api/riff/batchSetRiffCardsDueTime` https://github.com/siyuan-note/siyuan/issues/10423
|
||||
|
||||
deckLock.Lock()
|
||||
defer deckLock.Unlock()
|
||||
|
||||
waitForSyncingStorages()
|
||||
|
||||
deck := Decks[builtinDeckID]
|
||||
if nil == deck {
|
||||
return
|
||||
}
|
||||
|
||||
for _, cardDue := range cardDues {
|
||||
card := deck.GetCard(cardDue.ID)
|
||||
if nil == card {
|
||||
continue
|
||||
}
|
||||
|
||||
due, parseErr := time.Parse("20060102150405", cardDue.Due)
|
||||
if nil != parseErr {
|
||||
logging.LogErrorf("parse due time [%s] failed: %s", cardDue.Due, err)
|
||||
err = parseErr
|
||||
return
|
||||
}
|
||||
|
||||
card.SetDue(due)
|
||||
}
|
||||
|
||||
if err = deck.Save(); nil != err {
|
||||
logging.LogErrorf("save deck [%s] failed: %s", builtinDeckID, err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func ResetFlashcards(typ, id, deckID string, blockIDs []string) {
|
||||
// Support resetting the learning progress of flashcards https://github.com/siyuan-note/siyuan/issues/9564
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue