make 'forget card' undoable; remove checkpoint() in set_due_date

This commit is contained in:
Damien Elmes 2021-03-12 16:13:50 +10:00
parent 9ba02b5ca6
commit 24762261d9
4 changed files with 5 additions and 3 deletions

View File

@ -17,3 +17,4 @@ undo-update-tag = Update Tag
undo-update-note = Update Note
undo-update-card = Update Card
undo-update-deck = Update Deck
undo-forget-card = Forget Card

View File

@ -58,7 +58,6 @@ def set_due_date_dialog(
on_done()
mw.checkpoint(tr(TR.ACTIONS_SET_DUE_DATE))
mw.taskman.with_progress(set_due, after_set)
@ -78,7 +77,6 @@ def forget_cards(
on_done()
mw.checkpoint(tr(TR.ACTIONS_FORGET))
mw.taskman.with_progress(
lambda: mw.col.sched.schedule_cards_as_new(card_ids), on_done_wrapper
)

View File

@ -9,6 +9,7 @@ use crate::{
notes::NoteID,
search::SortMode,
types::Usn,
undo::UndoableOpKind,
};
use rand::seq::SliceRandom;
use std::collections::{HashMap, HashSet};
@ -105,7 +106,7 @@ impl Collection {
pub fn reschedule_cards_as_new(&mut self, cids: &[CardID], log: bool) -> Result<()> {
let usn = self.usn()?;
let mut position = self.get_next_card_position();
self.transact(None, |col| {
self.transact(Some(UndoableOpKind::ScheduleAsNew), |col| {
col.storage.set_search_table_to_card_ids(cids, true)?;
let cards = col.storage.all_searched_cards_in_search_order()?;
for mut card in cards {

View File

@ -12,6 +12,7 @@ pub enum UndoableOpKind {
RemoveDeck,
RemoveNote,
RenameDeck,
ScheduleAsNew,
SetDueDate,
Suspend,
UnburyUnsuspend,
@ -38,6 +39,7 @@ impl Collection {
UndoableOpKind::RemoveDeck => TR::DecksDeleteDeck,
UndoableOpKind::RemoveNote => TR::StudyingDeleteNote,
UndoableOpKind::RenameDeck => TR::ActionsRenameDeck,
UndoableOpKind::ScheduleAsNew => TR::UndoForgetCard,
UndoableOpKind::SetDueDate => TR::ActionsSetDueDate,
UndoableOpKind::Suspend => TR::StudyingSuspend,
UndoableOpKind::UnburyUnsuspend => TR::UndoUnburyUnsuspend,