revlog entry should not be deleted when undoing preview card

The plan is to add a revlog entry when previewing in the future; this
is just a temporary fix.
This commit is contained in:
Damien Elmes 2020-08-19 16:44:06 +10:00
parent 8a9a9591cb
commit d266f9a80a
2 changed files with 14 additions and 7 deletions

View file

@ -538,10 +538,12 @@ table.review-log {{ {revlog_style} }}
# Undo # Undo
########################################################################## ##########################################################################
# this data structure is a mess, and will be updated soon
# in the review case, [1, "Review", [firstReviewedCard, secondReviewedCard, ...], wasLeech]
# in the checkpoint case, [2, "action name"]
# wasLeech should have been recorded for each card, not globally
def clearUndo(self) -> None: def clearUndo(self) -> None:
# [type, undoName, data]
# type 1 = review; type 2 = checkpoint
self._undo = None self._undo = None
def undoName(self) -> Any: def undoName(self) -> Any:
@ -577,7 +579,10 @@ table.review-log {{ {revlog_style} }}
c.note().flush() c.note().flush()
# write old data # write old data
c.flush() c.flush()
# and delete revlog entry # and delete revlog entry if not previewing
conf = self.sched._cardConf(c)
previewing = conf["dyn"] and not conf["resched"]
if not previewing:
last = self.db.scalar( last = self.db.scalar(
"select id from revlog where cid = ? " "order by id desc limit 1", c.id "select id from revlog where cid = ? " "order by id desc limit 1", c.id
) )

View file

@ -131,6 +131,8 @@ class Scheduler:
if card.odue: if card.odue:
card.odue = 0 card.odue = 0
# note: when adding revlog entries in the future, make sure undo
# code deletes the entries
def _answerCardPreview(self, card: Card, ease: int) -> None: def _answerCardPreview(self, card: Card, ease: int) -> None:
assert 1 <= ease <= 2 assert 1 <= ease <= 2