Skip to content
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

[HACK week] Product list - Add Favorites section #12287

Draft
wants to merge 48 commits into
base: feat/12274-mark-favorite
Choose a base branch
from

Conversation

selanthiraiyan
Copy link
Contributor

@selanthiraiyan selanthiraiyan commented Mar 15, 2024

Part of: #12274

Description

List favorite products under a new section in product list table view.

Changes

  • Limit the max number of products that can be marked as favorite to avoid taking too much space in product list screen. In future, we can consider making "Favorites" section collapsible to make space for the "All" section.
  • Load the favorites product IDs from remote and show the products under "Favorites" section.
  • Observe to user defaults and reload when a product is marked/removed as favorite.

Testing instructions

  • Login into the app
  • Navigate to Products tab
  • Open any product
  • Tap "…" from the action sheet tap "Mark as favorite"
  • Navigate back to the product list screen.
  • You should see the product under "Favorites" section
  • Open the same product again
  • Tap "…" -> "Remove from a favourite" on it to remove the product from the favourite list.
  • Navigate back to the product list screen and validate that the "Favorites" section is updated.
  • Mark a few products to the favorites section.
  • Switch stores and ensure that the products marked as favorite are still marked as favorite.
  • Log out and log into the same store again. Validate that the favorite products list is cleared after logout.

Screenshots

Simulator Screen Recording - iPhone 15 Pro - 2024-03-15 at 20 16 26


  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

@selanthiraiyan selanthiraiyan added the feature: product list Related to the product list. label Mar 15, 2024
@selanthiraiyan selanthiraiyan added this to the 17.9 milestone Mar 15, 2024
@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Mar 15, 2024

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 Numberpr12287-b8bff6a
Version19.0
Bundle IDcom.automattic.alpha.woocommerce
Commitb8bff6a
App Center BuildWooCommerce - Prototype Builds #9625
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.

@selanthiraiyan selanthiraiyan marked this pull request as ready for review March 16, 2024 11:28
Copy link
Contributor

@itsmeichigo itsmeichigo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works as described in the PR description 👍 I have a few concerns:

  • Regarding the logic of the previous PR, I wonder if we should switch to saving favorite products in a local file with GeneralAppSettings rather than user defaults. IMO we should keep only simpler checks in user defaults, especially those that require synchronous requests. Favorite products might fit better with local file storage.
  • I'm unsure about the limit of the favorite items, as it's unclear to users when their older items are removed. We should keep all items and if that's too clustering, we can keep the feature under a feature flag before adding the view more option.

@@ -21,7 +21,7 @@ struct FavoriteProductsUseCase {
func markAsFavorite(productID: Int64) {
if var productIdDict = productIdDict {
let existingFavProductIDs = productIdDict[idAsString] ?? []
productIdDict[idAsString] = Array(Set(existingFavProductIDs + [productID]))
productIdDict[idAsString] = Array(Set(existingFavProductIDs + [productID])).suffix(Constants.favoriteProductsMaxLimit)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting this limit would remove the older items from the favorite list right? I don't think this is easy for users to understand, they might question where the other items go. Should we keep the list under the feature flag and add the view more option when we have time?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have removed this limit now as we added a way to expand/collapse the favorites section.

@bozidarsevo bozidarsevo modified the milestones: 17.9, 18.0 Mar 21, 2024
@selanthiraiyan selanthiraiyan removed this from the 18.0 milestone Mar 27, 2024
@selanthiraiyan selanthiraiyan marked this pull request as draft March 27, 2024 03:57
@selanthiraiyan
Copy link
Contributor Author

Thanks for the review, Huong! I am marking the PR as a draft until I get time to address the feedback.

guard let self else { return }
if let sort = settings.sort {
sortOrder = ProductsSortOrder(rawValue: sort) ?? .default
private func syncLocalProductsSettings() async throws -> StoredProductSettings.Setting {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made this method async and the rest are just indentation changes.

@selanthiraiyan
Copy link
Contributor Author

👋 @itsmeichigo , Thank you for the review and input. 🙇

I have pushed the necessary changes to make the favorites section collapse/expand. The PR is ready for another round of review.

Please note that I don't check for feature flag anywhere because,

  • The favorites section will be displayed only if there are favorite products.
  • The action buttons are enabled only if the feature flag is turned on. [HACK week] Product form - Action buttons to mark/remove as favorite #12284 This means that users can mark a product favorite only if the feature flag is turned on.
  • Checking feature flag inside ProductsViewController further complicates the code and might create edge case issues.

Changes include

  • Two sections in products table view. "Favorites" and "All"
  • "Favorites" section can be collapsed and expanded by the user.
  • Custom section header view with a button to collapse/expand section.
  • Remove background from PlainTextSectionHeaderView for using this in products table view. This isn't used anywhere else.
  • Callback when a product is marked or removed as favorite. We reload the tableview from this callback to update favorites section.

Known scrolling issue

When you select a product from the "Favorites" section and navigate back, the product will be selected in the "All" section

@jaclync 👋 Kindly share if you have any ideas or input about this issue. Thank you!

Demo

iPhone

Simulator.Screen.Recording.-.iPhone.15.Pro.Max.-.2024-06-14.at.17.31.20.mp4

iPad

Rotated.mov

@selanthiraiyan selanthiraiyan marked this pull request as ready for review June 14, 2024 12:15
@selanthiraiyan selanthiraiyan added this to the 19.2 milestone Jun 14, 2024
Copy link
Contributor

@itsmeichigo itsmeichigo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works as described (again). I appreciate your efforts, but I have some suggestions for improvements:

  • Having the favorite list as a section comes with a few complications like the selection state you mentioned. I also see that when selecting a filter, showing the favorite section can be misleading as the section is not filtered.
  • Some minor UI issues: the product list has a divider at the top, while there's no divider between the Favorites and All sections, which looks odd. There should be a divider between the sections for better clarity:

For a simpler UX, we can remove the Favorite section and update the product rows with an additional star icon for favorite items instead. Then, we can add an option to see only favorite items in the Filter list.

@selanthiraiyan
Copy link
Contributor Author

Thanks again for the review, Huong!

For a simpler UX, we can remove the Favorite section and update the product rows with an additional star icon for favorite items instead. Then, we can add an option to see only favorite items in the Filter list.

This is a good suggestion. I will try to address this when I find time. I will mark the PR as a draft until then.

@selanthiraiyan selanthiraiyan removed this from the 19.2 milestone Jun 18, 2024
@selanthiraiyan selanthiraiyan marked this pull request as draft June 18, 2024 07:59
@dangermattic
Copy link
Collaborator

1 Message
📖 This PR is still a Draft: some checks will be skipped.

Generated by 🚫 Danger

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature: product list Related to the product list.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants