only update active when selecting deck/resetting
We were previously doing this every time a card was answered.
This commit is contained in:
parent
f747063752
commit
1cddd6d23e
@ -104,9 +104,6 @@ class DeckManager:
|
|||||||
deck["name"] = name
|
deck["name"] = name
|
||||||
self.update(deck)
|
self.update(deck)
|
||||||
|
|
||||||
# fixme
|
|
||||||
self.maybeAddToActive()
|
|
||||||
|
|
||||||
# fixme
|
# fixme
|
||||||
hooks.deck_added(deck)
|
hooks.deck_added(deck)
|
||||||
|
|
||||||
@ -248,12 +245,6 @@ class DeckManager:
|
|||||||
except anki.rsbackend.ExistsError:
|
except anki.rsbackend.ExistsError:
|
||||||
raise DeckRenameError("deck already exists")
|
raise DeckRenameError("deck already exists")
|
||||||
|
|
||||||
# self.decks[str(g["id"])] = g
|
|
||||||
self.maybeAddToActive()
|
|
||||||
# mark registry changed, but don't bump mod time
|
|
||||||
|
|
||||||
# self.save()
|
|
||||||
|
|
||||||
def rename(self, g: Dict[str, Any], newName: str) -> None:
|
def rename(self, g: Dict[str, Any], newName: str) -> None:
|
||||||
"Rename deck prefix to NAME if not exists. Updates children."
|
"Rename deck prefix to NAME if not exists. Updates children."
|
||||||
g["name"] = newName
|
g["name"] = newName
|
||||||
@ -262,7 +253,6 @@ class DeckManager:
|
|||||||
|
|
||||||
# fixme: ensure rename of b in a::b::c generates new b
|
# fixme: ensure rename of b in a::b::c generates new b
|
||||||
# fixme: renaming may have altered active did order
|
# fixme: renaming may have altered active did order
|
||||||
# self.maybeAddToActive()
|
|
||||||
|
|
||||||
def renameForDragAndDrop(self, draggedDeckDid: int, ontoDeckDid: Any) -> None:
|
def renameForDragAndDrop(self, draggedDeckDid: int, ontoDeckDid: Any) -> None:
|
||||||
draggedDeck = self.get(draggedDeckDid)
|
draggedDeck = self.get(draggedDeckDid)
|
||||||
@ -452,11 +442,6 @@ class DeckManager:
|
|||||||
intTime(),
|
intTime(),
|
||||||
)
|
)
|
||||||
|
|
||||||
def maybeAddToActive(self) -> None:
|
|
||||||
# reselect current deck, or default if current has disappeared
|
|
||||||
c = self.current()
|
|
||||||
self.select(c["id"])
|
|
||||||
|
|
||||||
def cids(self, did: int, children: bool = False) -> Any:
|
def cids(self, did: int, children: bool = False) -> Any:
|
||||||
if not children:
|
if not children:
|
||||||
return self.col.db.list("select id from cards where did=?", did)
|
return self.col.db.list("select id from cards where did=?", did)
|
||||||
@ -494,6 +479,10 @@ class DeckManager:
|
|||||||
self.col.conf["activeDecks"] = [did] + [a[1] for a in actv]
|
self.col.conf["activeDecks"] = [did] + [a[1] for a in actv]
|
||||||
self.col.setMod()
|
self.col.setMod()
|
||||||
|
|
||||||
|
# don't use this, it will likely go away
|
||||||
|
def update_active(self):
|
||||||
|
self.select(self.current()["id"])
|
||||||
|
|
||||||
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"]
|
||||||
|
@ -60,6 +60,7 @@ class Scheduler:
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
def reset(self) -> None:
|
def reset(self) -> None:
|
||||||
|
self.col.decks.update_active()
|
||||||
self._updateCutoff()
|
self._updateCutoff()
|
||||||
self._resetLrn()
|
self._resetLrn()
|
||||||
self._resetRev()
|
self._resetRev()
|
||||||
|
@ -25,6 +25,7 @@ def test_basic():
|
|||||||
assert deck.decks.active() == [parentId]
|
assert deck.decks.active() == [parentId]
|
||||||
# let's create a child
|
# let's create a child
|
||||||
childId = deck.decks.id("new deck::child")
|
childId = deck.decks.id("new deck::child")
|
||||||
|
deck.sched.reset()
|
||||||
# it should have been added to the active list
|
# it should have been added to the active list
|
||||||
assert deck.decks.selected() == parentId
|
assert deck.decks.selected() == parentId
|
||||||
assert deck.decks.active() == [parentId, childId]
|
assert deck.decks.active() == [parentId, childId]
|
||||||
|
Loading…
Reference in New Issue
Block a user