On 2.1.49. I have some data in a
JSON file that gets loaded into my cards.
As I’m reviewing, and make changes to this file I’m able to see the live on my cards without needing to restart anki. In fact any file I change in collections.media works this way
However, after upgrading to 2.1.60 this doesn’t work anymore. Instead, I have to re-launch Anki, which is a pain for my use case.
Was this is this an intended change? Is there any way I can keep the lovely 2.1.60 but still get live refresh
There was a media change in 2.1.66 could you check it out?
Media check now automatically extracts images that have been embedded in fields.
Releases · ankitects/anki · GitHub
Not really, if we added it back, would need to launch a new version, 23.12 or 24.xx>
abdo
December 15, 2023, 10:04pm
3
I don’t think it’s exactly an intended change, but was made as part of a fix for a CSS issue. For context:
committed 02:06AM - 14 Dec 21 UTC
When we updated to flask 2.0, the default caching time changed to
0. When settin… g the HTML of a new card side in the DOM, the browser
first removes the existing content (including styling), then sends a
HTTP request to us to check whether the file has changed or not. By the
time the answer has arrived, the browser has repainted without the
styling, and thus we get a flicker.
A side-effect of reverting to flask 1.x behaviour is that external changes
to media files will not be reflected in Anki for an hour, unless Anki
is restarted, or the caches are cleared manually with an add-on. An
alternative approach would be to pre-fetch the css files like we do with
images, but there are other things like fonts to think about as well.
Closes #1455
committed 11:47AM - 16 Dec 21 UTC
* Preload external css files to prevent flash of unstyled content
This is an … implementation of the approach mentioned in the commit
message of 46b85d5.
* Tweak max_age value for css files
Ensure that css preloading works even on a slow PC.
You can work around it for now with a simple add-on. Here’s an example of how to do that:
if gc("open pdfs from other paths than the default path"):
return LocalFileRequest(root=pdf_folder_path, path=justfilename)
else:
return _old(path)
mediasrv._extract_addon_request = wrap(mediasrv._extract_addon_request,
_extract_pdf_request, 'around')
@flask_app.after_request
def disable_caching_for_pdf(response: Response) -> None:
# Disable caching for PDF so that modifications are reflected
# when reopening the file shortly after the modification
if response.mimetype == "application/pdf":
response.cache_control.max_age = 0
return response
def my_helper(editor, menu):
filefld = [f["ord"] for f in editor.note.model()['flds'] if f['name'] == gc("field_for_filename")]
if not filefld:
return
1 Like
system
Closed
January 14, 2024, 10:04pm
4
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.