NF: default_deck_id as a constant
Otherwise it's not clear what this 1 represents
This commit is contained in:
parent
3b6802530d
commit
b8f715ffea
@ -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
|
||||
|
||||
|
@ -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(
|
||||
|
@ -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("&", "&&"))
|
||||
|
Loading…
Reference in New Issue
Block a user