Skip to content
This repository has been archived by the owner on Oct 4, 2023. It is now read-only.

Always fetch content node images from cache #2319

Merged
merged 2 commits into from
Nov 29, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion packages/mobile/src/hooks/useContentNodeImage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ const createImageSourceWithSizes = ({
return {
width,
height: width,
uri: createUri(size)
uri: createUri(size),
// A CID is a unique identifier of a piece of content,
// so we can always rely on a cached value
// https://reactnative.dev/docs/images#cache-control-ios-only
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ios only? 👀
is the bug also on android?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to build something better here long term (sounds like @sliptype has some progress on it too!).

I believe that react native image does pretty intelligently cache, but since this flag exists, I figure worth turning on for iOS?
https://rangle.io/blog/image-caching-in-react-native/

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed that the image does load offline on android, so the caching must be present in some fashion. Can't guarantee this always, though I guess

cache: 'force-cache'
}
})
}
Expand Down