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

[Woo POS] Hide cancellation errors when refreshing #15077

Merged
merged 7 commits into from
Feb 6, 2025

Conversation

joshheald
Copy link
Contributor

@joshheald joshheald commented Feb 6, 2025

Part of: #14869
Merge after: #15060

Description

This PR prevents us showing an error when the pull to refresh network task is cancelled.

The cancellation can happen when we do something else to change the state of the item list, in particular, loading a new page.

In this case, the cancellation of the refresh is the right thing to do – we want to only complete the next page, not refresh, show the first page and add a random page to the end of the results.

Steps to reproduce

It's a bit tricky! Easier if you set your page size small.

  1. Launch the app and open POS
  2. Pull to refresh and quickly scroll to load a new page
  3. Load more new pages
  4. Pull to refresh and quickly scroll to load a new page
  5. Observe that either:
    a. The first page of results is shown (if PTR succeeded), or
    b. The next page of results is shown with all previous pages above it (if PTR was cancelled)

Testing information

Screenshots

don.t.show.errors.from.cancelling.a.pull.to.refresh.mp4

  • I have considered if this change warrants user-facing release notes and have added them to 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:

  • 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.

If we change the view content while the refresh is ongoing, e.g. by loading a new page, the refresh request will be cancelled.

It doesn’t make sense to show that as an error to the user.

Instead, we swallow that error, and set the state back to `loaded` with all the items that we’ve got up to now.
@joshheald joshheald added type: task An internally driven task. feature: POS labels Feb 6, 2025
@joshheald joshheald added this to the 21.7 milestone Feb 6, 2025
@joshheald joshheald requested a review from staskus February 6, 2025 11:18
@joshheald joshheald marked this pull request as ready for review February 6, 2025 11:18
@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Feb 6, 2025

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 Numberpr15077-b896d25
Version21.6
Bundle IDcom.automattic.alpha.woocommerce
Commitb896d25
App Center BuildWooCommerce - Prototype Builds #12841
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.

Base automatically changed from issue/14869-use-observation-to-fix-refresh-issue to trunk February 6, 2025 12:29
@dangermattic
Copy link
Collaborator

1 Warning
⚠️ This PR is assigned to the milestone 21.7. This milestone is due in less than 2 days.
Please make sure to get it merged by then or assign it to a milestone with a later deadline.

Generated by 🚫 Danger

Copy link
Contributor

@staskus staskus left a comment

Choose a reason for hiding this comment

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

Works well! Tested on iPad Air M2 18.2 device. Confirmed that .requestCancelled is caught 👍

@joshheald joshheald enabled auto-merge February 6, 2025 15:51
@joshheald joshheald merged commit ceb70bd into trunk Feb 6, 2025
13 of 15 checks passed
@joshheald joshheald deleted the issue/14869-hide-cancellation-errors-from-the-user branch February 6, 2025 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature: POS type: task An internally driven task.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants