fix shared deck conf warning

This commit is contained in:
Damien Elmes 2020-05-17 14:37:59 +10:00
parent b9b837e7bd
commit 252eb3a444
2 changed files with 6 additions and 13 deletions

View file

@ -63,9 +63,6 @@ class DeckManager:
def __init__(self, col: anki.storage._Collection) -> None: def __init__(self, col: anki.storage._Collection) -> None:
self.col = col.weakref() self.col = col.weakref()
self.decks = DecksDictProxy(col) self.decks = DecksDictProxy(col)
# do not access this directly!
# self._cache: Dict[int, ] = {}
# self.decks = {}
def save(self, g: Dict = None) -> None: def save(self, g: Dict = None) -> None:
"Can be called with either a deck or a deck configuration." "Can be called with either a deck or a deck configuration."
@ -78,8 +75,6 @@ class DeckManager:
self.update_config(g) self.update_config(g)
return return
else: else:
# g["mod"] = intTime()
# g["usn"] = self.col.usn()
self.update(g) self.update(g)
# legacy # legacy
@ -396,10 +391,9 @@ class DeckManager:
grp["conf"] = id grp["conf"] = id
self.save(grp) self.save(grp)
# fixme: expensive
def didsForConf(self, conf) -> List: def didsForConf(self, conf) -> List:
dids = [] dids = []
for deck in list(self.decks.values()): for deck in self.all():
if "conf" in deck and deck["conf"] == conf["id"]: if "conf" in deck and deck["conf"] == conf["id"]:
dids.append(deck["id"]) dids.append(deck["id"])
return dids return dids
@ -483,6 +477,9 @@ class DeckManager:
def update_active(self): def update_active(self):
self.select(self.current()["id"]) self.select(self.current()["id"])
# Parents/children
#############################################################
def children(self, did: int) -> List[Tuple[Any, Any]]: def children(self, did: int) -> List[Tuple[Any, Any]]:
"All children of did, as (name, id)." "All children of did, as (name, id)."
name = self.get(did)["name"] name = self.get(did)["name"]

View file

@ -103,13 +103,9 @@ class DeckConf(QDialog):
self.saveConf() self.saveConf()
conf = self.confList[idx] conf = self.confList[idx]
self.deck["conf"] = conf["id"] self.deck["conf"] = conf["id"]
self.mw.col.decks.save(self.deck)
self.loadConf() self.loadConf()
cnt = 0 cnt = len(self.mw.col.decks.didsForConf(conf))
for d in self.mw.col.decks.all():
if d["dyn"]:
continue
if d["conf"] == conf["id"]:
cnt += 1
if cnt > 1: if cnt > 1:
txt = _( txt = _(
"Your changes will affect multiple decks. If you wish to " "Your changes will affect multiple decks. If you wish to "