You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Right now, images that we use in both the webview and React Native (user uploads, avatars, reaction emoji) are downloaded by both, independently. Instead, we should have them share a cache.
We can explicitly add a cache, which both the webview and the lightbox share. The webview side of this I don't think is too hard — there's already a rewriteImageUrls function that can be co-opted for this purpose. I haven't peeked much at the lightbox code, but I suspect it's similarly easy to fix. The big questions I see are:
How is the cache implemented? Should it be an actual local HTTP server (exposed only to the Zulip app), or just some shared code that knows that cached images are kept on disk in a specific place?
What should the cache invalidation policy be like (presumably we should follow the Cache-control headers that the server sends?)
This has the advantage that we can also use this cache for things like avatar and custom emoji images, which are similarly shared between react-native code and webview code.
Write some JS code to get a URL, returning data from the cache if available (this probably requires some careful thinking about how authentication/etc works)
Expose that code to the webview, via a OutboundEvent/InboundEvent pair to get the file contents for a given URL
When the webview wants to render an image, it sends the OutboundEvent, waits for the inbound event, reads the image data, and loads it into the image
Right now, images that we use in both the webview and React Native (user uploads, avatars, reaction emoji) are downloaded by both, independently. Instead, we should have them share a cache.
As I wrote in #4349:
For storage, this seems like another case where we might want to use sqlite, probably having a table with [URL, data, expiration time, realm].
I can think of two ways to then use that:
The janky way
The non-janky way
I plan to continue to look into this more, I'm just filing this issue so that we have somewhere to track this.
The text was updated successfully, but these errors were encountered: