From 252eb3a44476795b4ded821cfe664a3255e0cf87 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Sun, 17 May 2020 14:37:59 +1000 Subject: [PATCH] fix shared deck conf warning --- pylib/anki/decks.py | 11 ++++------- qt/aqt/deckconf.py | 8 ++------ 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/pylib/anki/decks.py b/pylib/anki/decks.py index e20d5d47f..a6ddf8ca7 100644 --- a/pylib/anki/decks.py +++ b/pylib/anki/decks.py @@ -63,9 +63,6 @@ class DeckManager: def __init__(self, col: anki.storage._Collection) -> None: self.col = col.weakref() self.decks = DecksDictProxy(col) - # do not access this directly! - # self._cache: Dict[int, ] = {} - # self.decks = {} def save(self, g: Dict = None) -> None: "Can be called with either a deck or a deck configuration." @@ -78,8 +75,6 @@ class DeckManager: self.update_config(g) return else: - # g["mod"] = intTime() - # g["usn"] = self.col.usn() self.update(g) # legacy @@ -396,10 +391,9 @@ class DeckManager: grp["conf"] = id self.save(grp) - # fixme: expensive def didsForConf(self, conf) -> List: dids = [] - for deck in list(self.decks.values()): + for deck in self.all(): if "conf" in deck and deck["conf"] == conf["id"]: dids.append(deck["id"]) return dids @@ -483,6 +477,9 @@ class DeckManager: def update_active(self): self.select(self.current()["id"]) + # Parents/children + ############################################################# + def children(self, did: int) -> List[Tuple[Any, Any]]: "All children of did, as (name, id)." name = self.get(did)["name"] diff --git a/qt/aqt/deckconf.py b/qt/aqt/deckconf.py index b0c8dafff..acb6b30d8 100644 --- a/qt/aqt/deckconf.py +++ b/qt/aqt/deckconf.py @@ -103,13 +103,9 @@ class DeckConf(QDialog): self.saveConf() conf = self.confList[idx] self.deck["conf"] = conf["id"] + self.mw.col.decks.save(self.deck) self.loadConf() - cnt = 0 - for d in self.mw.col.decks.all(): - if d["dyn"]: - continue - if d["conf"] == conf["id"]: - cnt += 1 + cnt = len(self.mw.col.decks.didsForConf(conf)) if cnt > 1: txt = _( "Your changes will affect multiple decks. If you wish to "