Expose skip_undo_entry

https://forums.ankiweb.net/t/porting-tips-for-anki-23-10/35916/4
This commit is contained in:
Damien Elmes 2023-10-22 10:21:03 +10:00
parent 59d89dd9f1
commit f9de92ee09

View file

@ -480,28 +480,32 @@ class Collection(DeprecatedNamesMixin):
def get_card(self, id: CardId) -> Card: def get_card(self, id: CardId) -> Card:
return Card(self, id) return Card(self, id)
def update_cards(self, cards: Sequence[Card]) -> OpChanges: def update_cards(
"""Save card changes to database, and add an undo entry.""" self, cards: Sequence[Card], skip_undo_entry: bool = False
) -> OpChanges:
"""Save card changes to database."""
return self._backend.update_cards( return self._backend.update_cards(
cards=[c._to_backend_card() for c in cards], skip_undo_entry=False cards=[c._to_backend_card() for c in cards], skip_undo_entry=skip_undo_entry
) )
def update_card(self, card: Card) -> OpChanges: def update_card(self, card: Card, skip_undo_entry: bool = False) -> OpChanges:
"""Save card changes to database, and add an undo entry.""" """Save card changes to database."""
return self.update_cards([card]) return self.update_cards([card], skip_undo_entry=skip_undo_entry)
def get_note(self, id: NoteId) -> Note: def get_note(self, id: NoteId) -> Note:
return Note(self, id=id) return Note(self, id=id)
def update_notes(self, notes: Sequence[Note]) -> OpChanges: def update_notes(
"""Save note changes to database, and add an undo entry.""" self, notes: Sequence[Note], skip_undo_entry: bool = False
) -> OpChanges:
"""Save note changes to database."""
return self._backend.update_notes( return self._backend.update_notes(
notes=[n._to_backend_note() for n in notes], skip_undo_entry=False notes=[n._to_backend_note() for n in notes], skip_undo_entry=skip_undo_entry
) )
def update_note(self, note: Note) -> OpChanges: def update_note(self, note: Note, skip_undo_entry: bool = False) -> OpChanges:
"""Save note changes to database, and add an undo entry.""" """Save note changes to database."""
return self.update_notes([note]) return self.update_notes([note], skip_undo_entry=skip_undo_entry)
# Utils # Utils
########################################################################## ##########################################################################