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:
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"]

View file

@ -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 "