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] Split container and list states with new pagination #14727

Merged

Conversation

joshheald
Copy link
Contributor

@joshheald joshheald commented Dec 18, 2024

Closes: #14693

Description

This updates the Items view state to split out container states from list states.

It also lays the groundwork for having a hierarchy of lists including variation details.

Testing information

This changes how the state is represented for the item list as a container.

Testing should cover:

  • initial loading (full screen)
  • Empty state (full screen)
  • Error state (full screen – with retry)
  • Using items in the cart
  • Scrolling down to load the next page
  • Pull to refresh

Errors during 2nd and subsequent page loads and pull to refresh will still be full screen, as will empty state.


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

@joshheald joshheald requested a review from jaclync December 18, 2024 16:39
@joshheald joshheald added type: task An internally driven task. feature: POS labels Dec 18, 2024
@joshheald joshheald added this to the 21.3 milestone Dec 18, 2024
@dangermattic
Copy link
Collaborator

dangermattic commented Dec 18, 2024

1 Warning
⚠️ View files have been modified, but no screenshot or video is included in the pull request. Consider adding some for clarity.

Generated by 🚫 Danger

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Dec 18, 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 Numberpr14727-00fc51f
Version21.2
Bundle IDcom.automattic.alpha.woocommerce
Commit00fc51f
App Center BuildWooCommerce - Prototype Builds #12237
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.

Copy link
Contributor

@jaclync jaclync left a comment

Choose a reason for hiding this comment

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

Apology for the overlapping changes that took longer than I expected to wrap up, I foresee some conflicts in the items controller. Left some initial comments, will review it in depth tomorrow.

WooCommerce/Classes/POS/Models/ItemsStackState.swift Outdated Show resolved Hide resolved
Networking/Networking/Remote/ProductsRemote.swift Outdated Show resolved Hide resolved
private var isInitialLoading: Bool = true
private let paginationTracker: PaginationTracker
private(set) var itemsViewStatePublisher: any Publisher<ItemsViewState, Never>
private var itemsViewStateSubject: PassthroughSubject<ItemsViewState, Never> = .init()
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reasons not having this as a CurrentValueSubject and use its value when needed, or a @Published var?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not a published var because it's not an observable object (and I wanted to keep POSModel as the only one, partly for possibly easier moves to Observable.

It could be a CurrentValueSubject, I just haven't tried it. No time left today but feel free to make that change if you think it'd be an improvement...

Copy link
Contributor

Choose a reason for hiding this comment

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

I see, I think it's an improvement not having to need a separate private variable with didSet to sync with the subject. Updated in 00fc51f and it seems to work fine from testing.

Base automatically changed from feat/14699-pagination-headers-products to trunk December 19, 2024 16:12
@joshheald
Copy link
Contributor Author

@jaclync this has the pagination changes merged in now – testing since then has been limited.

There's definitely still an issue when the page size is small, on pull to refresh – the pull to refresh view translation seems to trigger the loadNextItems as well, so sometimes all the items get cleared out and you see the skeleton view.

That gesture needs a work anyway, because of the pre-existing issues, so I'm treating it as out of scope for this PR.

Let me know what you think about the approach

@joshheald joshheald marked this pull request as ready for review December 19, 2024 17:44
@joshheald joshheald modified the milestones: 21.3, 21.4 Dec 19, 2024
@jaclync jaclync self-assigned this Dec 20, 2024
Copy link
Contributor

@jaclync jaclync left a comment

Choose a reason for hiding this comment

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

Looks good so far with testing, I confirm the issue where pulling to refresh without a full height of items triggers the network request twice even with page size 100. Created an issue #14735.

Updating the PR from the comments, and will test again.

WooCommerce/Classes/POS/Presentation/ItemListView.swift Outdated Show resolved Hide resolved

POSConnectivityView()
}
.environment(\.floatingControlAreaSize,
CGSizeMake(floatingSize.width + Constants.floatingControlHorizontalOffset,
floatingSize.height + Constants.floatingControlVerticalOffset))
.environment(\.posBackgroundAppearance, posModel.paymentState != .processingPayment ? .primary : .secondary)
.animation(.easeInOut, value: posModel.itemListState == .initialLoading)
.animation(.easeInOut, value: posModel.itemsViewState.containerState == .loading)
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice having a separate container state from the changes in this file 👍

WooCommerce/Classes/POS/Utils/PreviewHelpers.swift Outdated Show resolved Hide resolved
…ueSubject` so that it does not require another private variable with didSet.
Copy link
Contributor

@jaclync jaclync left a comment

Choose a reason for hiding this comment

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

LGTM from testing with WPCOM account login and site credentials login, and the scenarios in the testing steps :shipit: Just the issue when the item list is short on pull-to-refresh, which I will look into as a separate fix.

@joshheald
Copy link
Contributor Author

LGTM from testing with WPCOM account login and site credentials login, and the scenarios in the testing steps :shipit: Just the issue when the item list is short on pull-to-refresh, which I will look into as a separate fix.

Thanks for all the improvements @jaclync!

@joshheald joshheald merged commit bfe0243 into trunk Dec 20, 2024
14 of 15 checks passed
@joshheald joshheald deleted the issue/14693-split-container-and-list-states-with-new-pagination branch December 20, 2024 08:01
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.

[Woo POS] [Variable Products] Split ItemListState into container and list states
4 participants