From 24762261d9c3282eb8813c14aa074e32ba6effce Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Fri, 12 Mar 2021 16:13:50 +1000 Subject: [PATCH] make 'forget card' undoable; remove checkpoint() in set_due_date --- ftl/core/undo.ftl | 1 + qt/aqt/scheduling.py | 2 -- rslib/src/scheduler/new.rs | 3 ++- rslib/src/undo/ops.rs | 2 ++ 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/ftl/core/undo.ftl b/ftl/core/undo.ftl index e3ae07497..c2e95f1e9 100644 --- a/ftl/core/undo.ftl +++ b/ftl/core/undo.ftl @@ -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 diff --git a/qt/aqt/scheduling.py b/qt/aqt/scheduling.py index 6e28e1ff2..f16d49b1a 100644 --- a/qt/aqt/scheduling.py +++ b/qt/aqt/scheduling.py @@ -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 ) diff --git a/rslib/src/scheduler/new.rs b/rslib/src/scheduler/new.rs index e74bdc49a..7fce556b1 100644 --- a/rslib/src/scheduler/new.rs +++ b/rslib/src/scheduler/new.rs @@ -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 { diff --git a/rslib/src/undo/ops.rs b/rslib/src/undo/ops.rs index d006101ed..562470ab6 100644 --- a/rslib/src/undo/ops.rs +++ b/rslib/src/undo/ops.rs @@ -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,