Replace calls to deprecated flush() with col.update_note/card
The changes passes skip_undo_entry to update_note/card, because the implementation of the deprecated flush() method did so. Whether this is the right decision for our use case was not checked/thought about.
This commit is contained in:
parent
dc96cdc76c
commit
cc027f8ab8
@ -829,7 +829,7 @@ class AnkiConnect:
|
|||||||
pictureObjectOrList = note.get('picture')
|
pictureObjectOrList = note.get('picture')
|
||||||
self.addMedia(ankiNote, pictureObjectOrList, util.MediaType.Picture)
|
self.addMedia(ankiNote, pictureObjectOrList, util.MediaType.Picture)
|
||||||
|
|
||||||
ankiNote.flush()
|
self.collection().update_note(ankiNote, skip_undo_entry=True);
|
||||||
|
|
||||||
|
|
||||||
@util.api()
|
@util.api()
|
||||||
@ -893,8 +893,8 @@ class AnkiConnect:
|
|||||||
# Update the tags
|
# Update the tags
|
||||||
anki_note.tags = new_tags
|
anki_note.tags = new_tags
|
||||||
|
|
||||||
# Flush changes to ensure they are saved
|
# Update note to ensure changes are saved
|
||||||
anki_note.flush()
|
collection.update_note(anki_note, skip_undo_entry=True);
|
||||||
|
|
||||||
@util.api()
|
@util.api()
|
||||||
def updateNoteTags(self, note, tags):
|
def updateNoteTags(self, note, tags):
|
||||||
@ -948,7 +948,7 @@ class AnkiConnect:
|
|||||||
if note.has_tag(tag_to_replace):
|
if note.has_tag(tag_to_replace):
|
||||||
note.remove_tag(tag_to_replace)
|
note.remove_tag(tag_to_replace)
|
||||||
note.add_tag(replace_with_tag)
|
note.add_tag(replace_with_tag)
|
||||||
note.flush()
|
self.collection().update_note(note, skip_undo_entry=True);
|
||||||
|
|
||||||
self.window().requireReset()
|
self.window().requireReset()
|
||||||
self.window().progress.finish()
|
self.window().progress.finish()
|
||||||
@ -965,7 +965,7 @@ class AnkiConnect:
|
|||||||
if note.has_tag(tag_to_replace):
|
if note.has_tag(tag_to_replace):
|
||||||
note.remove_tag(tag_to_replace)
|
note.remove_tag(tag_to_replace)
|
||||||
note.add_tag(replace_with_tag)
|
note.add_tag(replace_with_tag)
|
||||||
note.flush()
|
self.collection().update_note(note, skip_undo_entry=True);
|
||||||
|
|
||||||
self.window().requireReset()
|
self.window().requireReset()
|
||||||
self.window().progress.finish()
|
self.window().progress.finish()
|
||||||
@ -984,7 +984,7 @@ class AnkiConnect:
|
|||||||
|
|
||||||
couldSetEaseFactors.append(True)
|
couldSetEaseFactors.append(True)
|
||||||
ankiCard.factor = easeFactors[i]
|
ankiCard.factor = easeFactors[i]
|
||||||
ankiCard.flush()
|
self.collection().update_card(ankiCard, skip_undo_entry=True)
|
||||||
|
|
||||||
return couldSetEaseFactors
|
return couldSetEaseFactors
|
||||||
|
|
||||||
@ -1014,7 +1014,7 @@ class AnkiConnect:
|
|||||||
ankiCard = self.getCard(card)
|
ankiCard = self.getCard(card)
|
||||||
for i, key in enumerate(keys):
|
for i, key in enumerate(keys):
|
||||||
setattr(ankiCard, key, newValues[i])
|
setattr(ankiCard, key, newValues[i])
|
||||||
ankiCard.flush()
|
self.collection().update_card(ankiCard, skip_undo_entry=True)
|
||||||
result.append(True)
|
result.append(True)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
result.append([False, str(e)])
|
result.append([False, str(e)])
|
||||||
|
Loading…
Reference in New Issue
Block a user