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

Core Data: Optimize storage usage in ProductCategoryStore

Open itsmeichigo opened this issue 1 year ago • 2 comments

Part of #14091

Description

This PR continues the optimization for the Core Data usage in the app by improving the usage in ProductCatgoryStore:

  • Replaced the deprecated access to writerDerivedStorage with the new method performAndSave.
  • Combine the deletion and upsertion when syncing the first page of categories.
  • Move the deletion of unused categories to the background.
  • Optimized fetch requests when upserting categories by fetching all categories at one.

Steps to reproduce

  • Log in to a test store.
  • Navigate to the Products tab and create a new product or open an existing one.
  • Select Categories and confirm that the list is loaded successfully.
  • Add a new category and confirm that it works as expected.
  • Edit and delete the new category. Confirm that both work as expected.

Testing information

Tested on simulator iPhone 16 Pro iOS 18.0 and confirmed that:

  • Category list loads correctly.
  • Adding/Editing/Deleting categories 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:

  • [ ] 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.
  • [ ] Ensure Adequate Unit Test Coverage: The changes are reasonably covered by unit tests or an explanation is provided in the PR description.
  • [ ] 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 18 '24 07: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 Numberpr14151-f0dc15b
Version20.8
Bundle IDcom.automattic.alpha.woocommerce
Commitf0dc15bd423ad4571d707de078aa95389eb45529
App Center BuildWooCommerce - Prototype Builds #11225
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.

wpmobilebot avatar Oct 18 '24 07:10 wpmobilebot

Testing note:

Tested in iPhone 15 Simulator with iOS 17.5 ✅ Edited an existing product, went to Categories and items were loaded properly ✅ Category creation worked correctly ✅ Category editing worked correctly ✅ Category deletion worked correctly

hafizrahman avatar Oct 18 '24 13:10 hafizrahman