From 972059251993c87c3395dc5d09cd96c3bc53c7ef Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Mon, 20 Sep 2021 22:02:44 +1000 Subject: [PATCH] temporary fix for error on deleting (#1374) --- qt/aqt/browser/browser.py | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/qt/aqt/browser/browser.py b/qt/aqt/browser/browser.py index a71cf2e15..ffc38fe6b 100644 --- a/qt/aqt/browser/browser.py +++ b/qt/aqt/browser/browser.py @@ -9,7 +9,13 @@ import aqt import aqt.forms from anki._legacy import deprecated from anki.cards import Card, CardId -from anki.collection import Collection, Config, OpChanges, SearchNode +from anki.collection import ( + Collection, + Config, + OpChanges, + OpChangesWithCount, + SearchNode, +) from anki.consts import * from anki.errors import NotFoundError from anki.lang import without_unicode_isolation @@ -54,6 +60,7 @@ from aqt.utils import ( saveState, showWarning, skip_if_selection_is_empty, + tooltip, tr, ) @@ -593,11 +600,16 @@ class Browser(QMainWindow): return nids = self.table.get_selected_note_ids() - # select the next card if there is one - self.focusTo = self.editor.currentField - self.table.to_next_row() - remove_notes(parent=self, note_ids=nids).run_in_background() + def after_remove(changes: OpChangesWithCount) -> None: + tooltip(tr.browsing_cards_deleted(count=changes.count)) + # select the next card if there is one + self.focusTo = self.editor.currentField + self.table.to_next_row() + + remove_notes(parent=self, note_ids=nids).success( + after_remove + ).run_in_background() # legacy