diff --git a/pylib/anki/decks.py b/pylib/anki/decks.py index 3c38df99c..24439c728 100644 --- a/pylib/anki/decks.py +++ b/pylib/anki/decks.py @@ -31,6 +31,7 @@ DeckDict = Dict[str, Any] DeckConfigDict = Dict[str, Any] DeckID = NewType("DeckID", int) +default_deck_id = 1 class DecksDictProxy: @@ -248,7 +249,7 @@ class DeckManager: def get(self, did: Union[int, str], default: bool = True) -> Optional[DeckDict]: if not did: if default: - return self.get_legacy(1) + return self.get_legacy(default_deck_id) else: return None id = int(did) @@ -256,7 +257,7 @@ class DeckManager: if deck: return deck elif default: - return self.get_legacy(1) + return self.get_legacy(default_deck_id) else: return None diff --git a/pylib/anki/notes.py b/pylib/anki/notes.py index 1f2895e08..27893275f 100644 --- a/pylib/anki/notes.py +++ b/pylib/anki/notes.py @@ -97,7 +97,7 @@ class Note: ) -> anki.cards.Card: card = anki.cards.Card(self.col) card.ord = ord - card.did = 1 + card.did = anki.decks.default_deck_id model = custom_note_type or self.model() template = copy.copy( diff --git a/qt/aqt/deckchooser.py b/qt/aqt/deckchooser.py index 70056aaa0..a6fc08da8 100644 --- a/qt/aqt/deckchooser.py +++ b/qt/aqt/deckchooser.py @@ -3,6 +3,7 @@ from typing import Optional +from anki.decks import default_deck_id from aqt import AnkiQt from aqt.qt import * from aqt.utils import TR, HelpPage, shortcut, tr @@ -70,7 +71,7 @@ class DeckChooser(QHBoxLayout): def _ensure_selected_deck_valid(self) -> None: if not self.mw.col.decks.get(self._selected_deck_id, default=False): - self.selected_deck_id = 1 + self.selected_deck_id = default_deck_id def _update_button_label(self) -> None: self.deck.setText(self.selected_deck_name().replace("&", "&&"))