fix finished screen not showing when learning cards due later

This commit is contained in:
Damien Elmes 2021-01-25 21:11:03 +10:00
parent 110a481a24
commit 31a3add848
2 changed files with 17 additions and 17 deletions

View File

@ -176,9 +176,11 @@ class Scheduler:
# current deck points to a missing deck # current deck points to a missing deck
self.newCount = 0 self.newCount = 0
self.revCount = 0 self.revCount = 0
self._immediate_learn_count = 0
else: else:
self.newCount = node.new_count self.newCount = node.new_count
self.revCount = node.review_count self.revCount = node.review_count
self._immediate_learn_count = node.learn_count
def counts(self, card: Optional[Card] = None) -> Tuple[int, int, int]: def counts(self, card: Optional[Card] = None) -> Tuple[int, int, int]:
counts = [self.newCount, self.lrnCount, self.revCount] counts = [self.newCount, self.lrnCount, self.revCount]
@ -188,6 +190,10 @@ class Scheduler:
new, lrn, rev = counts new, lrn, rev = counts
return (new, lrn, rev) return (new, lrn, rev)
def _is_finished(self):
"Don't use this, it is a stop-gap until this code is refactored."
return not any((self.newCount, self.revCount, self._immediate_learn_count))
def dueForecast(self, days: int = 7) -> List[Any]: def dueForecast(self, days: int = 7) -> List[Any]:
"Return counts over next DAYS. Includes today." "Return counts over next DAYS. Includes today."
daysd: Dict[int, int] = dict( daysd: Dict[int, int] = dict(

View File

@ -158,11 +158,10 @@ class Overview:
shareLink = '<a class=smallLink href="review">Reviews and Updates</a>' shareLink = '<a class=smallLink href="review">Reviews and Updates</a>'
else: else:
shareLink = "" shareLink = ""
table_text = self._table() if self.mw.col.sched._is_finished():
if not table_text:
# deck is finished
self._show_finished_screen() self._show_finished_screen()
return return
table_text = self._table()
content = OverviewContent( content = OverviewContent(
deck=deck["name"], deck=deck["name"],
shareLink=shareLink, shareLink=shareLink,
@ -196,14 +195,9 @@ class Overview:
return '<div class="descfont descmid description %s">%s</div>' % (dyn, desc) return '<div class="descfont descmid description %s">%s</div>' % (dyn, desc)
def _table(self) -> Optional[str]: def _table(self) -> Optional[str]:
"Return table text if deck is not finished."
counts = list(self.mw.col.sched.counts()) counts = list(self.mw.col.sched.counts())
finished = not sum(counts)
but = self.mw.button but = self.mw.button
if finished: return """
return None
else:
return """
<table width=400 cellpadding=5> <table width=400 cellpadding=5>
<tr><td align=center valign=top> <tr><td align=center valign=top>
<table cellspacing=5> <table cellspacing=5>
@ -213,14 +207,14 @@ class Overview:
</table> </table>
</td><td align=center> </td><td align=center>
%s</td></tr></table>""" % ( %s</td></tr></table>""" % (
tr(TR.ACTIONS_NEW), tr(TR.ACTIONS_NEW),
counts[0], counts[0],
tr(TR.SCHEDULING_LEARNING), tr(TR.SCHEDULING_LEARNING),
counts[1], counts[1],
tr(TR.STUDYING_TO_REVIEW), tr(TR.STUDYING_TO_REVIEW),
counts[2], counts[2],
but("study", tr(TR.STUDYING_STUDY_NOW), id="study", extra=" autofocus"), but("study", tr(TR.STUDYING_STUDY_NOW), id="study", extra=" autofocus"),
) )
_body = """ _body = """
<center> <center>