woocommerce-ios
woocommerce-ios copied to clipboard
Core Data: Optimize storage usage in ProductReviewStore
Closes: #14133
Description
This PR updates ProductReviewStore for better usage of storage following the recent updates of CoreDataManager. Specifically:
- Moved write operations to the background for
resetStoredProductReviews,deleteStoredProductReview, andmoderateReview. - Updated
upsertStoredProductReviewsInBackgroundto use the new methodperformAndSave. - Updated
RetrieveProductReviewFromNoteUseCaseto receive the storage manager instead of storage.
Steps to reproduce
- Log in to a store with existing products and reviews.
- Navigate to the Menu tab > select Reviews. Confirm that the review list is loaded successfully.
- Change the status for a review and confirm that it works correctly.
- Switch to another store, confirm that there's no warning in Xcode console saying "Write operations for ProductReview should only be done on a background context".
- Build the app to a physical device then add a review to a product on your test store on the web.
- When the notification for the review comes in your device, tap it and confirm that the review details are loaded successfully.
Testing information
Tested on device iPhone 16 Pro iOS 18.0.1 and confirmed that loading/moderating/opening review notifications work as expected.
Screenshots
N/A
- [ ] I have considered if this change warrants user-facing release notes and have added them to
RELEASE-NOTES.txtif necessary.
TODO: @itsmeichigo to update the release notes before merging.
Reviewer (or Author, in the case of optional code reviews):
Please make sure these conditions are met before approving the PR, or request changes if the PR needs improvement:
- [x] The PR is small and has a clear, single focus, or a valid explanation is provided in the description. If needed, please request to split it into smaller PRs.
- [x] Ensure Adequate Unit Test Coverage: The changes are reasonably covered by unit tests or an explanation is provided in the PR description.
- [x] Manual Testing: The author listed all the tests they ran, including smoke tests when needed (e.g., for refactorings). The reviewer confirmed that the PR works as expected on all devices (phone/tablet) and no regressions are added.
📲 You can test the changes from this Pull Request in WooCommerce iOS by scanning the QR code below to install the corresponding build.
| App Name | ||
| Build Number | pr14134-d2a57c0 | |
| Version | 20.8 | |
| Bundle ID | com.automattic.alpha.woocommerce | |
| Commit | d2a57c07bfce2ebebdd28b1355ddc51b0ea64e8b | |
| App Center Build | WooCommerce - Prototype Builds #11205 |
Testing note:
Tested in iPhone 15 Simulator with iOS 17.5
✅ Menu tab > Reviews shows reviews correctly ✅ Changing review status works ✅ No Xcode console warning when switching to another store
Tested in iPhone 14 Pro with iOS 17.4.1
✅ Notification appears when a review is added on the web ✅ Tapping notification opens to the review details correctly