-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RNMobile] Add enableCaching
param to fetch request on Android
#31186
Conversation
Size Change: 0 B Total Size: 1.31 MB ℹ️ View Unchanged
|
93a3842
to
f549c32
Compare
if ( isAndroid ) { | ||
return RNReactNativeGutenbergBridge.fetchRequest( path, enableCaching ); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Request caching is only available on Android.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good approach since the bridge code on iOS does not contain enableCaching
in the attached bridge code snippet and in the line below.
func fetchRequest(_ path: String, resolver: @escaping RCTPromiseResolveBlock, rejecter: @escaping RCTPromiseRejectBlock) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, actually, I was surprised that we have the caching feature only on Android 🤔 .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for these changes @fluiddot I tested the behavior utilizing the WP Android PR with a local metro server ( the generated APK on the PR does not support reusable blocks since it's still devOnly
). Making changes to the reusable block's content on the web resulted in instant changes in the post when it was opened on mobile. I left a few comments I want to hear your thoughts on.
Thank you very much @jd-alexander for the review ❤️ ! Oh true, the reusable block is still devOnly so it can only be tested in development mode. I have a test branch (
Awesome! I've just pushed a commit with changes regarding your comments 👍 . |
I updated the test branch with the latest changes in case you want to use an installable build for testing. |
More than happy to 😄
Thanks! I am going to have a look 🙇🏾 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works as expected. Tested using the installable builds for the test branches. Thanks for adding the unit tests 🙇🏾 LGTM 🚢
gutenberg-mobile
PR: wordpress-mobile/gutenberg-mobile#3419WordPress-Android
PR: wordpress-mobile/WordPress-Android#14529Description
On Android the network requests coming from RN are always cached for 10 minutes, in most cases this behavior is ok but for content that can be modified often like the reusable blocks, we should have a way to bypass the cache.
For this purpose, I've added a param to the fetch request function that is exposed to RN and also add a constant with the endpoint patterns that shouldn't be cached when a network request is made. For now we'll only disable caching for the blocks (reusable blocks) endpoint.
How has this been tested?
Screenshots
N/A
Types of changes
New feature
Checklist:
*.native.js
files for terms that need renaming or removal).