woocommerce / woocommerce-ios

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

[Woo POS] Technical: Improvements on `PointOfSaleDashboardViewModel` state handling #13380

Open iamgabrielma opened 1 month ago

iamgabrielma commented 1 month ago

This is a follow-up from https://github.com/woocommerce/woocommerce-ios/pull/13361

Ref: https://github.com/woocommerce/woocommerce-ios/pull/13361#discussion_r1682265685

My suggestion was to move such checks to VM ( PointOfSaleDashboardViewModel), so it would be viewModel.isCartShown

Ref: https://github.com/woocommerce/woocommerce-ios/pull/13361#discussion_r1682272374

isEmptyOrError likely doesn't belong in ItemListViewModel as well, especially if we have it here just to use within PointOfSaleDashboardView

if in the future all the different ViewModels will need to keep accessing the state of ItemListViewModel. It may also suggest that the state belongs to the parent PointOfSaleDashboardViewModel and then can be passed and observed by child VMs.

In order to make tests easier we can also extract the existing MockPOSItemProvider from the ItemListViewModelTests extension, so it can also be used on PointOfSaleDashboardViewModelTests

dangermattic commented 1 month ago

Thanks for reporting! 👍