woocommerce / woocommerce-ios

WooCommerce iOS app
https://www.woocommerce.com/mobile
GNU General Public License v2.0
314 stars 113 forks source link

[Woo POS] Simplify TotalsViewModel #14473

Closed joshheald closed 1 day ago

joshheald commented 1 day ago

Part of: #14458

Description

This PR removes the posModel and cardReaderService dependencies from the TotalsViewModel.

These actions can simply happen within the aggregate model.

One notable point; the connectCardReader action on the reader not connected error (shown on the right hand side when viewing totals with no reader connected) now uses the environment object to call connectCardReader on the aggregate model.

Not having to do any manual injection here really simplifies the view and view model, in my opinion.

Testing information

This PR requires general testing of the checkout and payment flow, including card reader disconnection and reconnection.

In particular note that the card reader gets prepared for payment when you connect it on the Totals View, using either button. This should not happen when connecting the reader on the item selection screen.

The connection/disconnection required some slight test setup changes, but the existing tests on the aggregate model already covered the behaviour.


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:

dangermattic commented 1 day ago
2 Warnings
:warning: View files have been modified, but no screenshot or video is included in the pull request. Consider adding some for clarity.
:warning: This PR is assigned to the milestone 21.2. 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 :no_entry_sign: Danger

wpmobilebot commented 1 day ago

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 Numberpr14473-46b2e09
Version21.1
Bundle IDcom.automattic.alpha.woocommerce
Commit46b2e09d8c06b278193ff8312747142e7d980b07
App Center BuildWooCommerce - Prototype Builds #11700

Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.