don't hide learning count on congrats screen when learning is overdue

The v3 scheduler will delay the final card from being shown twice in
a row, but the overdue case was being treated the same as the no-learning
case, leading to the message being hidden.
This commit is contained in:
Damien Elmes 2021-08-02 15:24:46 +10:00
parent 3cec1a35dc
commit 070f57fcc5
2 changed files with 10 additions and 7 deletions

View file

@ -21,10 +21,13 @@ impl Collection {
let info = self.storage.congrats_info(&deck, today)?; let info = self.storage.congrats_info(&deck, today)?;
let is_filtered_deck = deck.is_filtered(); let is_filtered_deck = deck.is_filtered();
let deck_description = deck.rendered_description(); let deck_description = deck.rendered_description();
let secs_until_next_learn = ((info.next_learn_due as i64) let secs_until_next_learn = if info.next_learn_due == 0 {
- self.learn_ahead_secs() as i64 // signal to the frontend that no learning cards are due later
- TimestampSecs::now().0) 86_400
.max(0) as u32; } else {
((info.next_learn_due as i64) - self.learn_ahead_secs() as i64 - TimestampSecs::now().0)
.max(60) as u32
};
Ok(pb::CongratsInfoResponse { Ok(pb::CongratsInfoResponse {
learn_remaining: info.learn_count, learn_remaining: info.learn_count,
review_remaining: info.review_remaining, review_remaining: info.review_remaining,
@ -56,7 +59,7 @@ mod test {
have_sched_buried: false, have_sched_buried: false,
have_user_buried: false, have_user_buried: false,
is_filtered_deck: false, is_filtered_deck: false,
secs_until_next_learn: 0, secs_until_next_learn: 86_400,
bridge_commands_supported: true, bridge_commands_supported: true,
deck_description: "".to_string() deck_description: "".to_string()
} }

View file

@ -15,8 +15,8 @@ export async function getCongratsInfo(): Promise<Scheduler.CongratsInfoResponse>
export function buildNextLearnMsg(info: Scheduler.CongratsInfoResponse): string { export function buildNextLearnMsg(info: Scheduler.CongratsInfoResponse): string {
const secsUntil = info.secsUntilNextLearn; const secsUntil = info.secsUntilNextLearn;
// next learning card not due (/ until tomorrow)? // next learning card not due today?
if (secsUntil == 0 || secsUntil > 86_400) { if (secsUntil >= 86_400) {
return ""; return "";
} }