mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 06:22:22 -04:00
compat fixes for add-on usage of col.decks.active()
This commit is contained in:
parent
9f3f6bab7d
commit
590ef6da0a
2 changed files with 16 additions and 2 deletions
|
@ -477,7 +477,8 @@ class DeckManager:
|
||||||
self.col.reset()
|
self.col.reset()
|
||||||
|
|
||||||
def active(self) -> List[DeckId]:
|
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
|
selected = get_current_id
|
||||||
|
|
||||||
|
|
|
@ -11,12 +11,14 @@ as '2' internally.
|
||||||
|
|
||||||
from __future__ import annotations
|
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
|
import anki._backend.backend_pb2 as _pb
|
||||||
from anki.cards import Card, CardId
|
from anki.cards import Card, CardId
|
||||||
from anki.collection import OpChanges
|
from anki.collection import OpChanges
|
||||||
from anki.consts import *
|
from anki.consts import *
|
||||||
|
from anki.decks import DeckId
|
||||||
|
from anki.errors import DBError
|
||||||
from anki.scheduler.base import CongratsInfo
|
from anki.scheduler.base import CongratsInfo
|
||||||
from anki.scheduler.legacy import SchedulerBaseWithLegacy
|
from anki.scheduler.legacy import SchedulerBaseWithLegacy
|
||||||
from anki.types import assert_exhaustive
|
from anki.types import assert_exhaustive
|
||||||
|
@ -239,3 +241,14 @@ class Scheduler(SchedulerBaseWithLegacy):
|
||||||
assert False, "invalid ease"
|
assert False, "invalid ease"
|
||||||
|
|
||||||
return self._interval_for_state(new_state)
|
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 []
|
||||||
|
|
Loading…
Reference in a new issue