Skip to content

Commit

Permalink
Do not bury suspended cards (#1447)
Browse files Browse the repository at this point in the history
* Skip burying for suspended cards

* Inform about number of buried cards

(cherry picked from commit 3cdb3d7)
  • Loading branch information
RumovZ authored and dae committed Oct 26, 2021
1 parent 86c56f9 commit dc80804
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 27 deletions.
7 changes: 5 additions & 2 deletions ftl/core/studying.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@ studying-buried-siblings = Buried Siblings
studying-bury = Bury
studying-bury-card = Bury Card
studying-bury-note = Bury Note
studying-card-buried = Card buried.
studying-card-suspended = Card suspended.
studying-card-was-a-leech = Card was a leech.
studying-cards-buried =
{ $count ->
[one] { $count } card buried.
*[other] { $count } cards buried.
}
studying-cards-will-be-automatically-returned-to = Cards will be automatically returned to their original decks after you review them.
studying-continue = Continue
studying-delete-note = Delete Note
Expand All @@ -25,7 +29,6 @@ studying-manually-buried-cards = Manually Buried Cards
studying-mark-note = Mark Note
studying-more = More
studying-no-cards-are-due-yet = No cards are due yet.
studying-note-buried = Note buried.
studying-note-suspended = Note suspended.
studying-pause-audio = Pause Audio
studying-please-run-toolsempty-cards = Please run Tools>Empty Cards
Expand Down
14 changes: 6 additions & 8 deletions qt/aqt/reviewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1029,16 +1029,14 @@ def suspend_current_card(self) -> None:
).success(lambda _: tooltip(tr.studying_card_suspended())).run_in_background()

def bury_current_note(self) -> None:
bury_notes(
parent=self.mw,
note_ids=[self.card.nid],
).success(lambda _: tooltip(tr.studying_note_buried())).run_in_background()
bury_notes(parent=self.mw, note_ids=[self.card.nid],).success(
lambda res: tooltip(tr.studying_cards_buried(count=res.count))
).run_in_background()

def bury_current_card(self) -> None:
bury_cards(
parent=self.mw,
card_ids=[self.card.id],
).success(lambda _: tooltip(tr.studying_card_buried())).run_in_background()
bury_cards(parent=self.mw, card_ids=[self.card.id],).success(
lambda res: tooltip(tr.studying_cards_buried(count=res.count))
).run_in_background()

def delete_current_note(self) -> None:
# need to check state because the shortcut is global to the main
Expand Down
37 changes: 20 additions & 17 deletions rslib/src/scheduler/bury_and_suspend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,29 +92,32 @@ impl Collection {
let mut count = 0;
let usn = self.usn()?;
let sched = self.scheduler_version();
let desired_queue = match mode {
BuryOrSuspendMode::Suspend => CardQueue::Suspended,
BuryOrSuspendMode::BurySched => CardQueue::SchedBuried,
BuryOrSuspendMode::BuryUser => {
if sched == SchedulerVersion::V1 {
// v1 scheduler only had one bury type
CardQueue::SchedBuried
} else {
CardQueue::UserBuried
}
}
};

for original in self.storage.all_searched_cards()? {
let mut card = original.clone();
let desired_queue = match mode {
BuryOrSuspendMode::Suspend => CardQueue::Suspended,
BuryOrSuspendMode::BurySched => CardQueue::SchedBuried,
BuryOrSuspendMode::BuryUser => {
if card.queue != desired_queue {
// do not bury suspended cards as that would unsuspend them
if card.queue != CardQueue::Suspended {
if sched == SchedulerVersion::V1 {
// v1 scheduler only had one bury type
CardQueue::SchedBuried
} else {
CardQueue::UserBuried
card.remove_from_filtered_deck_restoring_queue(sched);
card.remove_from_learning();
}
card.queue = desired_queue;
count += 1;
self.update_card_inner(&mut card, original, usn)?;
}
};
if card.queue != desired_queue {
if sched == SchedulerVersion::V1 {
card.remove_from_filtered_deck_restoring_queue(sched);
card.remove_from_learning();
}
card.queue = desired_queue;
count += 1;
self.update_card_inner(&mut card, original, usn)?;
}
}

Expand Down

0 comments on commit dc80804

Please sign in to comment.