added removeEmptyNotes (#221)

* clearUnusedTags and replaceTags are added

* added clearUnusedTags and replaceTags

* added clearUnusedTags and replaceTags

* removed whitespaces and indentations

* removed white spaces and indentations

* added removeEmptyNotes
This commit is contained in:
Venkata Ramana 2021-01-05 07:31:56 +05:30 committed by GitHub
parent 311cb7e192
commit c55281d67a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 1 deletions

View File

@ -433,3 +433,24 @@
"error": null "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
}
```

View File

@ -1085,7 +1085,12 @@ class AnkiConnect:
finally: finally:
self.stopEditing() 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() @util.api()