NF: currentDeckID factorize odid or did

This commit is contained in:
Arthur Milchior 2021-03-25 13:57:25 +01:00 committed by Damien Elmes
parent 986efeed19
commit 3b6802530d
4 changed files with 10 additions and 7 deletions

View file

@ -163,21 +163,24 @@ class Card:
def startTimer(self) -> None:
self.timerStarted = time.time()
def currentDeckID(self) -> int:
return anki.decks.DeckID(self.odid or self.did)
def timeLimit(self) -> int:
"Time limit for answering in milliseconds."
conf = self.col.decks.confForDid(self.odid or self.did)
conf = self.col.decks.confForDid(self.currentDeckID())
return conf["maxTaken"] * 1000
def shouldShowTimer(self) -> bool:
conf = self.col.decks.confForDid(self.odid or self.did)
conf = self.col.decks.confForDid(self.currentDeckID())
return conf["timer"]
def replay_question_audio_on_answer_side(self) -> bool:
conf = self.col.decks.confForDid(self.odid or self.did)
conf = self.col.decks.confForDid(self.currentDeckID())
return conf.get("replayq", True)
def autoplay(self) -> bool:
return self.col.decks.confForDid(self.odid or self.did)["autoplay"]
return self.col.decks.confForDid(self.currentDeckID())["autoplay"]
def timeTaken(self) -> int:
"Time taken to answer card, in integer MS."

View file

@ -398,7 +398,7 @@ class Collection:
or current notetype.
"""
if card := current_review_card:
home_deck = card.odid or card.did
home_deck = card.currentDeckID()
else:
home_deck = 0

View file

@ -172,7 +172,7 @@ class TemplateRenderContext:
# add (most) special fields
fields["Tags"] = self._note.stringTags().strip()
fields["Type"] = self._note_type["name"]
fields["Deck"] = self._col.decks.name(self._card.odid or self._card.did)
fields["Deck"] = self._col.decks.name(self._card.currentDeckID())
fields["Subdeck"] = DeckManager.basename(fields["Deck"])
if self._template:
fields["Card"] = self._template["name"]

View file

@ -834,7 +834,7 @@ time = %(time)d;
qconnect(a.triggered, func)
def onOptions(self) -> None:
self.mw.onDeckConf(self.mw.col.decks.get(self.card.odid or self.card.did))
self.mw.onDeckConf(self.mw.col.decks.get(self.card.currentDeckID()))
def set_flag_on_current_card(self, desired_flag: int) -> None:
# need to toggle off?