woocommerce / woocommerce-android

WooCommerce Android app
https://www.woocommerce.com/mobile
GNU General Public License v2.0
277 stars 135 forks source link

[Product List] Fix product trashing failing to update product list #12834

Closed ThomazFB closed 3 weeks ago

ThomazFB commented 3 weeks ago

Why

Fix issue #12777 by introducing to the Product List awareness about when a product is being trashed.

The root cause of the issue is how the trashing action doesn't trigger an immediate event. It takes a few seconds to actually trigger the trashing to allow the user to undo the trashing from the Product List warning.

Due to this problem, it's possible to swipe to refresh while the trashing is not confirmed, causing the product to be reloaded from the store API and reappear in the Product list.

How

To solve this, two adjustments to the product list were necessary.

First, while the undo action is available to the user, the swipe to refresh is disabled. This shouldn't affect the user since it's disabled for a couple of seconds, and after the trashing is done, the Product List will be refreshed anyway.

This leads to the second adjustment: Once the trashing is confirmed, the Product List will be refreshed, and any subsequent swipe to refresh will be enqueued waiting for the Trashing request to finish. Loading the products from database will also be disabled, to avoid getting outdated data while the trashing request is not finished.

Screen Capture

Before

https://github.com/user-attachments/assets/8ef29003-0900-4baf-bf20-e3b6129d48c7

After

https://github.com/user-attachments/assets/b294e87c-6977-4b8b-ba6d-a89a9637c650

How to Test

  1. Navigate to product details screen
  2. From the overflow menu (3 dots in the toolbar), select the Trash Product option
  3. The app returns to the Product List screen with a message saying that the product has been trashed
  4. Verify the swipe to refresh is disabled for a few seconds and returns right after it
  5. Swipe to refresh as soon as available and ensure the trashed product never returns to the list

Update release notes:

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:

wpmobilebot commented 3 weeks ago
πŸ“² You can test the changes from this Pull Request in WooCommerce-Wear Android by scanning the QR code below to install the corresponding build.
App Name WooCommerce-Wear Android
Platform⌚️ Wear OS
FlavorJalapeno
Build TypeDebug
Commit3e6ebf290f4a3c419246a3eb4e368d5c7014f539
Direct Downloadwoocommerce-wear-prototype-build-pr12834-3e6ebf2.apk
wpmobilebot commented 3 weeks ago

πŸ“² You can test the changes from this Pull Request in WooCommerce Android by scanning the QR code below to install the corresponding build.

App Name WooCommerce Android
PlatformπŸ“± Mobile
FlavorJalapeno
Build TypeDebug
Commit3e6ebf290f4a3c419246a3eb4e368d5c7014f539
Direct Downloadwoocommerce-prototype-build-pr12834-3e6ebf2.apk
sentry-io[bot] commented 1 week ago

Suspect Issues

This pull request was deployed and Sentry observed the following issues:

Did you find this useful? React with a πŸ‘ or πŸ‘Ž