diff --git a/pylib/anki/decks.py b/pylib/anki/decks.py index 75673f36f..5718ed0b1 100644 --- a/pylib/anki/decks.py +++ b/pylib/anki/decks.py @@ -477,7 +477,8 @@ class DeckManager: self.col.reset() def active(self) -> List[DeckId]: - return self.col.sched.active_decks + # some add-ons assume this will always be non-empty + return self.col.sched.active_decks or [DeckId(1)] selected = get_current_id diff --git a/pylib/anki/scheduler/v3.py b/pylib/anki/scheduler/v3.py index a1489a984..f367c6c0b 100644 --- a/pylib/anki/scheduler/v3.py +++ b/pylib/anki/scheduler/v3.py @@ -11,12 +11,14 @@ as '2' internally. from __future__ import annotations -from typing import Literal, Sequence, Tuple, Union +from typing import List, Literal, Sequence, Tuple, Union import anki._backend.backend_pb2 as _pb from anki.cards import Card, CardId from anki.collection import OpChanges from anki.consts import * +from anki.decks import DeckId +from anki.errors import DBError from anki.scheduler.base import CongratsInfo from anki.scheduler.legacy import SchedulerBaseWithLegacy from anki.types import assert_exhaustive @@ -239,3 +241,14 @@ class Scheduler(SchedulerBaseWithLegacy): assert False, "invalid ease" return self._interval_for_state(new_state) + + # Other legacy + ################### + + # called by col.decks.active(), which add-ons are using + @property + def active_decks(self) -> List[DeckId]: + try: + return self.col.db.list("select id from active_decks") + except DBError: + return []