Skip to content

Commit 0d53ccc

Browse files
committed
loadFirstPage of coupons on happy path
1 parent 3119db1 commit 0d53ccc

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

WooCommerce/Classes/POS/Controllers/PointOfSaleCouponsController.swift

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,27 +18,34 @@ import protocol Yosemite.PointOfSaleItemServiceProtocol
1818

1919
@MainActor
2020
func loadItems(base: ItemListBaseItem) async {
21-
debugPrint("🍍 CouponsController::loadItems called")
22-
itemsViewState = ItemsViewState(containerState: .content, itemsStack: .init(root: .loaded([], hasMoreItems: false), itemStates: [:]))
21+
// TODO:
22+
// Handle unhappy path
23+
await loadFirstPage()
2324
}
2425

26+
@MainActor
2527
func refreshItems(base: ItemListBaseItem) async {
26-
await fetchItems()
28+
// TODO:
29+
// Handle unhappy path
30+
await loadFirstPage()
2731
}
2832

33+
@MainActor
2934
func loadNextItems(base: ItemListBaseItem) async {
30-
debugPrint("🍍 CouponsController::loadNextItems called")
31-
itemsViewState = ItemsViewState(containerState: .content, itemsStack: .init(root: .loaded([], hasMoreItems: false), itemStates: [:]))
35+
// TODO:
36+
// Pagination https://github.com/woocommerce/woocommerce-ios/issues/15343
37+
await loadFirstPage()
3238
}
3339
}
3440

3541
@available(iOS 17.0, *)
3642
private extension PointOfSaleCouponsController {
37-
func fetchItems() async {
43+
@MainActor
44+
func loadFirstPage() async {
3845
do {
39-
let items = try await itemProvider.providePointOfSaleItems(pageNumber: 1).items
46+
let coupons = try await itemProvider.providePointOfSaleItems(pageNumber: 1).items
4047
itemsViewState = ItemsViewState(containerState: .content,
41-
itemsStack: .init(root: .loaded(items, hasMoreItems: false),
48+
itemsStack: .init(root: .loaded(coupons, hasMoreItems: false),
4249
itemStates: [:]))
4350
} catch {
4451
debugPrint(error)

0 commit comments

Comments
 (0)