I’m loading a list of articles, each has a main image and I want to initially use a cached image on disk, if it’s not there then use a placeholder image until I manage to download and save them via HTTP.
Now, I can call my API to get the list of articles and run through them to create a file using Storage using something like
And, despite Storage missing a way of checking what files exist, I can maintain a file with a JSON array to manage it. (Hint: FUSE - a cache API would be gorgeous).
And I’m pretty certain that if I use an Observer for the images in question that I can replace the image with the downloaded one when it comes available.
So what is my problem?
My problem is how the heck do I reference myImageCache/2751963f7e234ddb4f04e34690112abf.jpg in the image tag or in FuseJS? The following, as expected, doesn’t work.
I was trying to extend the originals in Fuse, but was unable to do that because of restrictive permissions, so this imagesource does not handle memory allocations and things like that as well as the native fuse sources. However it should be a nice starting point to get you where you want in terms of caching.
When it’s trying to download the whole Page just locks up and jitters so I was hoping to eliminate that.
When I do this, some images are cached, others aren’t so I need finer grained control as the user expects to see all the images. Multiple retries seem to make less and less images available offline. See below for missing images and how it should look.
When I get a push notification I pull the article list and cache the images before showing the user the UI so it’s all ready to go.
The articles I am caching have multiple images in them so I cache them all so when the user selects an article from the list the HTML displayed refers to the local cached copy.
I was trying to extend the originals in Fuse, but was unable to do that because of restrictive permissions, so this imagesource does not handle memory allocations and things like that as well as the native fuse sources. However it should be a nice starting point to get you where you want in terms of caching.
matt@roxburghm.com wrote: Thats interesting. Given that I have saved an image to Storage via a Fetch how would I then reference said file in FuseJS to assign it to an tag.
There is no pure JS way of doing this yet. You have to create some Uno helpers.