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
This commit is contained in:
aldoWan 2024-02-18 20:45:10 +01:00 committed by Alex Yatskov
parent 2996476e03
commit d27f54a4fe

View File

@ -41,6 +41,7 @@ from anki.exporting import AnkiPackageExporter
from anki.importing import AnkiPackageImporter from anki.importing import AnkiPackageImporter
from anki.notes import Note from anki.notes import Note
from anki.errors import NotFoundError from anki.errors import NotFoundError
from anki.scheduler.base import ScheduleCardsAsNew
from aqt.qt import Qt, QTimer, QMessageBox, QCheckBox from aqt.qt import Qt, QTimer, QMessageBox, QCheckBox
from .web import format_exception_reply, format_success_reply from .web import format_exception_reply, format_success_reply
@ -1514,13 +1515,17 @@ class AnkiConnect:
result.append({}) result.append({})
return result return result
@util.api() @util.api()
def forgetCards(self, cards): def forgetCards(self, cards):
self.startEditing() self.startEditing()
scids = anki.utils.ids2str(cards) request = ScheduleCardsAsNew(
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) card_ids=cards,
log=True,
restore_position=True,
reset_counts=False,
context=None,
)
self.collection()._backend.schedule_cards_as_new(request)
@util.api() @util.api()
def relearnCards(self, cards): def relearnCards(self, cards):