diff --git a/ankiqt/ui/facteditor.py b/ankiqt/ui/facteditor.py
index b755e825d..1c7ac5e66 100644
--- a/ankiqt/ui/facteditor.py
+++ b/ankiqt/ui/facteditor.py
@@ -14,6 +14,7 @@ from ankiqt import ui
import ankiqt
from ankiqt.ui.utils import mungeQA, saveGeom, restoreGeom
from anki.hooks import addHook
+from sqlalchemy.exceptions import InvalidRequestError
clozeColour = "#0000ff"
@@ -38,6 +39,7 @@ class FactEditor(object):
self.changeTimer = None
self.lastCloze = None
addHook("deckClosed", self.deckClosedHook)
+ addHook("guiReset", self.refresh)
def setFact(self, fact, noFocus=False, check=False):
"Make FACT the current fact."
@@ -63,6 +65,15 @@ class FactEditor(object):
if self.deck.mediaDir(create=False):
self.initMedia()
+ def refresh(self):
+ if self.fact:
+ try:
+ self.deck.s.refresh(self.fact)
+ except InvalidRequestError:
+ # not attached to session yet, add cards dialog will handle
+ return
+ self.setFact(self.fact, check=True)
+
def focusFirst(self):
if self.focusTarget:
self.focusTarget.setFocus()
diff --git a/ankiqt/ui/main.py b/ankiqt/ui/main.py
index 8814ee2a2..f675a58a6 100644
--- a/ankiqt/ui/main.py
+++ b/ankiqt/ui/main.py
@@ -198,6 +198,7 @@ Please do not file a bug report with Anki.
""")
if count:
self.deck.rebuildCounts()
self.deck.rebuildQueue()
+ runHook("guiReset")
self.moveToState("initial")
def moveToState(self, state):