-
Notifications
You must be signed in to change notification settings - Fork 114
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
[Product] Update product tag store to migrate Core Data usage and fix a few issues #14511
Conversation
… to be as part of upsertion
📲 You can test the changes from this Pull Request in WooCommerce iOS by scanning the QR code below to install the corresponding build.
|
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.
Nice work @itsmeichigo, all works as expected (tested using iPhone 16 simulator, iOS 18.1)
One point though, it seems the cached data is not used anywhere, we always fetch tags from remote before showing them, I think a good improvement to do to this screen is to update it to show the cached data first, WDYT? I can create a ticket for this improvement if you agree.
guard tags.isEmpty == false else { | ||
return onCompletion(.success([])) | ||
} |
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.
I found it interesting that we need this check here, after checking the code, the issue is in the handling of tags in iOS, the logic in ProductTagsViewController
could use some optimization, as currently it always tries to create tags even the already added ones, and by extension causes the issue that you noticed.
Normally, the logic should be create just the new tags, and would speed up the process also (when the user picks just existing ones).
I'll create an issue to keep track of this improvement; for now, this fix here should be enough.
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.
Thank you!
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.
Since this is a simple fix, I sneaked it in c77d166.
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 @itsmeichigo for the additional improvement, this looks good, but my remark touches another point, currently the logic of iOS always triggers an API request to create the tags, but this should be needed only when the user adds a new one that doesn't already exist, when the user picks tags from the suggestions, we don't need to re-create them. The following screen recording shows what I mean (I'm selecting an existing tag, and yet we show a loading indicator and we send an API request):
Simulator.Screen.Recording.-.iPhone.16.-.2024-11-29.at.18.32.01.mp4
I created this ticket #14555 to keep track of this.
Thanks @hichamboushaba for the helpful feedback!
Nice observation! This is a simple fix also so I added an update in cd4946a. I also updated the release notes and PR description to take into account the new update. Please let me know if there is anything else needs updating. |
Part of #14091
Closes #14513
Description
This PR updates the usage of storage in
ProductTagStore
:writerDerivedStorage
with the new methodperformAndSave
for upserting product tags.deleteStoredProductTags
to be executed in the background.While testing the above changes, I found that even though we remove unused tags upon syncing, those tags are still displayed when selecting tags for products. The reason is that we are adding all the tags fetched from the remote to storage again eventually.
I fixed this by parsing the
count
property for product tags and use it to filter only used tags when syncing. This ensures that only used tags are recommended, similar to how the feature works in WooCommerce Core.Also: addressed #14513 by not triggering the tag creation endpoint when the tag list is empty.
Steps to reproduce
Testing information
Tested and confirmed with simulator iPhone 16 Pro iOS 18.1:
Screenshots
Simulator.Screen.Recording.-.iPhone.16.Pro.-.2024-11-26.at.15.27.13.mp4
RELEASE-NOTES.txt
if necessary.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: