From d27f54a4fe6de1b1ea86244c9d0cb36dce88a8b2 Mon Sep 17 00:00:00 2001 From: aldoWan Date: Sun, 18 Feb 2024 20:45:10 +0100 Subject: [PATCH] Ensured forgotten cards are correctly synchronized with ankiweb by using ScheduleCardsAsNew Resetting the database seemed not enough anymore, it's better to call the same function as ankiDroid is using: ScheduleCardsAsNew --- plugin/__init__.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/plugin/__init__.py b/plugin/__init__.py index 9620f3d..d5f0dff 100644 --- a/plugin/__init__.py +++ b/plugin/__init__.py @@ -41,6 +41,7 @@ from anki.exporting import AnkiPackageExporter from anki.importing import AnkiPackageImporter from anki.notes import Note from anki.errors import NotFoundError +from anki.scheduler.base import ScheduleCardsAsNew from aqt.qt import Qt, QTimer, QMessageBox, QCheckBox from .web import format_exception_reply, format_success_reply @@ -1514,13 +1515,17 @@ class AnkiConnect: result.append({}) return result - @util.api() def forgetCards(self, cards): self.startEditing() - scids = anki.utils.ids2str(cards) - self.collection().db.execute('update cards set type=0, queue=0, left=0, ivl=0, due=0, odue=0, factor=0 where id in ' + scids) - + request = ScheduleCardsAsNew( + card_ids=cards, + log=True, + restore_position=True, + reset_counts=False, + context=None, + ) + self.collection()._backend.schedule_cards_as_new(request) @util.api() def relearnCards(self, cards):