From 99081e422be631b1a0f012b93d83092440554977 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Thu, 13 May 2021 15:51:02 +1000 Subject: [PATCH] re-enable leech notification for test scheduler --- qt/aqt/reviewer.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/qt/aqt/reviewer.py b/qt/aqt/reviewer.py index be75661b2..8fc339172 100644 --- a/qt/aqt/reviewer.py +++ b/qt/aqt/reviewer.py @@ -379,13 +379,18 @@ class Reviewer: if not proceed: return - if v3 := self._v3: - assert isinstance(self.mw.col.sched, V3Scheduler) - answer = self.mw.col.sched.build_answer( + if (v3 := self._v3) and (sched := cast(V3Scheduler, self.mw.col.sched)): + answer = sched.build_answer( card=self.card, states=v3.next_states, rating=v3.rating_from_ease(ease) ) + + def after_answer(changes: OpChanges) -> None: + self._after_answering(ease) + if sched.state_is_leech(answer.new_state): + self.onLeech() + answer_card(parent=self.mw, answer=answer).success( - lambda _: self._after_answering(ease) + after_answer ).run_in_background(initiator=self) else: self.mw.col.sched.answerCard(self.card, ease) @@ -823,10 +828,11 @@ time = %(time)d; # Leeches ########################################################################## - def onLeech(self, card: Card) -> None: + def onLeech(self, card: Optional[Card] = None) -> None: # for now s = tr.studying_card_was_a_leech() - if card.queue < 0: + # v3 scheduler doesn't report this + if card and card.queue < 0: s += f" {tr.studying_it_has_been_suspended()}" tooltip(s)