woocommerce-ios
woocommerce-ios copied to clipboard
Core Data: Optimize storage usage in ProductCategoryStore
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
writerDerivedStoragewith the new methodperformAndSave. - 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.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:
- [ ] 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.
📲 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 | pr14151-f0dc15b | |
| Version | 20.8 | |
| Bundle ID | com.automattic.alpha.woocommerce | |
| Commit | f0dc15bd423ad4571d707de078aa95389eb45529 | |
| App Center Build | WooCommerce - Prototype Builds #11225 |
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