Skip to content

Commit

Permalink
🐛 The status of flashcards after re-reviewing the previous one is inc…
Browse files Browse the repository at this point in the history
  • Loading branch information
88250 committed Dec 26, 2023
1 parent 1f1b309 commit 8833f8b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions card.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ type Card interface {
// GetState 返回闪卡状态。
GetState() State

// Clone 返回闪卡的克隆。
Clone() Card

// Impl 返回具体的闪卡实现。
Impl() interface{}

Expand Down
14 changes: 14 additions & 0 deletions fsrs_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,3 +330,17 @@ func (card *FSRSCard) SetImpl(c interface{}) {
func (card *FSRSCard) GetState() State {
return State(card.C.State)
}

func (card *FSRSCard) Clone() Card {
data, err := gulu.JSON.MarshalJSON(card)
if nil != err {
logging.LogErrorf("marshal card failed: %s", err)
return nil
}
ret := &FSRSCard{}
if err = gulu.JSON.UnmarshalJSON(data, ret); nil != err {
logging.LogErrorf("unmarshal card failed: %s", err)
return nil
}
return ret
}

0 comments on commit 8833f8b

Please sign in to comment.