Merge pull request #1296 from hikaru-y/revert-1276-follow-up-preload-images

Revert "Follow-up to #1271 (Preload answer images)"
This commit is contained in:
Damien Elmes 2021-07-17 09:00:24 +10:00 committed by GitHub
commit 459f224c6e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 3 deletions

View File

@ -170,6 +170,7 @@ class Previewer(QDialog):
if not self._open:
return
c = self.card()
func = "_showQuestion"
ans_txt = ""
if not c:
txt = tr.qt_misc_please_select_1_card()
@ -189,7 +190,9 @@ class Previewer(QDialog):
# need to force reload even if answer
txt = c.question(reload=True)
ans_txt = c.answer()
if self._state == "answer":
func = "_showAnswer"
txt = ans_txt
txt = re.sub(r"\[\[type:[^]]+\]\]", "", txt)
@ -218,10 +221,12 @@ class Previewer(QDialog):
txt = gui_hooks.card_will_show(txt, c, f"preview{self._state.capitalize()}")
self._last_state = self._state_and_mod()
js: str
if self._state == "question":
js = f"_showQuestion({json.dumps(txt)}, {json.dumps(ans_txt)}, '{bodyclass}');"
ans_txt = self.mw.col.media.escape_media_filenames(ans_txt)
js = f"{func}({json.dumps(txt)}, {json.dumps(ans_txt)}, '{bodyclass}');"
else:
js = f"_showAnswer({json.dumps(txt)}, '{bodyclass}');"
js = f"{func}({json.dumps(txt)}, '{bodyclass}');"
self._web.eval(js)
self._card_changed = False

View File

@ -337,9 +337,10 @@ class Reviewer:
self._run_state_mutation_hook()
bodyclass = theme_manager.body_classes_for_card_ord(c.ord)
a = self.mw.col.media.escape_media_filenames(c.answer())
self.web.eval(
f"_showQuestion({json.dumps(q)}, {json.dumps(c.answer())}, '{bodyclass}');"
f"_showQuestion({json.dumps(q)}, {json.dumps(a)}, '{bodyclass}');"
)
self._update_flag_icon()
self._update_mark_icon()