woocommerce-ios icon indicating copy to clipboard operation
woocommerce-ios copied to clipboard

Core Data: Optimize storage usage in ProductReviewStore

Open itsmeichigo opened this issue 1 year ago • 2 comments

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, and moderateReview.
  • Updated upsertStoredProductReviewsInBackground to use the new method performAndSave.
  • Updated RetrieveProductReviewFromNoteUseCase to 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.txt if 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.

itsmeichigo avatar Oct 16 '24 08:10 itsmeichigo

WooCommerce iOS📲 You can test the changes from this Pull Request in WooCommerce iOS by scanning the QR code below to install the corresponding build.

App NameWooCommerce iOS WooCommerce iOS
Build Numberpr14134-d2a57c0
Version20.8
Bundle IDcom.automattic.alpha.woocommerce
Commitd2a57c07bfce2ebebdd28b1355ddc51b0ea64e8b
App Center BuildWooCommerce - Prototype Builds #11205
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.

wpmobilebot avatar Oct 16 '24 08:10 wpmobilebot

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

hafizrahman avatar Oct 18 '24 12:10 hafizrahman