diff --git a/actions/notes.md b/actions/notes.md index 83cc514..05510f3 100644 --- a/actions/notes.md +++ b/actions/notes.md @@ -433,3 +433,24 @@ "error": null } ``` + +* **removeEmptyNotes** + + Removes all the empty notes for the current user. + + *Sample request*: + ```json + { + "action": "removeEmptyNotes", + "version": 6 + } + ``` + + *Sample result*: + ```json + { + "result": null, + "error": null + } + ``` + \ No newline at end of file diff --git a/plugin/__init__.py b/plugin/__init__.py index 050ebf8..996c2b9 100644 --- a/plugin/__init__.py +++ b/plugin/__init__.py @@ -1085,7 +1085,12 @@ class AnkiConnect: finally: self.stopEditing() - + @util.api() + def removeEmptyNotes(self): + for model in self.collection().models.all(): + if self.collection().models.useCount(model) == 0: + self.collection().models.rem(model) + self.window().requireReset() @util.api()