Skip to content

Commit 35b4586

Browse files
committed
Restore loading bookings upon switching tab and sort items by start date
1 parent 3b3b78d commit 35b4586

File tree

3 files changed

+4
-7
lines changed

3 files changed

+4
-7
lines changed

WooCommerce/Classes/Bookings/BookingList/BookingListContainerViewModel.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,14 @@ enum BookingListTab: Int, CaseIterable {
4646
}
4747
}
4848

49-
func startDateBefore(currentDate: Date = Date()) -> Date? {
49+
func startDateBefore(currentDate: Date) -> Date? {
5050
switch self {
5151
case .today: currentDate.endOfDay(timezone: Self.utcTimeZone)
5252
case .upcoming, .all: nil
5353
}
5454
}
5555

56-
func startDateAfter(currentDate: Date = Date()) -> Date? {
56+
func startDateAfter(currentDate: Date) -> Date? {
5757
switch self {
5858
case .today: currentDate.startOfDay(timezone: Self.utcTimeZone)
5959
case .upcoming: currentDate.endOfDay(timezone: Self.utcTimeZone)

WooCommerce/Classes/Bookings/BookingList/BookingListView.swift

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,7 @@ struct BookingListView: View {
2424
}
2525
}
2626
.task {
27-
// Only load first page if no content is available.
28-
if viewModel.bookings.isEmpty {
29-
viewModel.loadBookings()
30-
}
27+
viewModel.loadBookings()
3128
}
3229
}
3330
}

WooCommerce/Classes/Bookings/BookingList/BookingListViewModel.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ final class BookingListViewModel: ObservableObject {
3535
predicates.append(NSPredicate(format: "startDate > %@", after as NSDate))
3636
}
3737
let combinedPredicate = NSCompoundPredicate(type: .and, subpredicates: predicates)
38-
let sortDescriptorByDate = NSSortDescriptor(key: "dateCreated", ascending: false)
38+
let sortDescriptorByDate = NSSortDescriptor(key: "startDate", ascending: false)
3939
let resultsController = ResultsController<StorageBooking>(storageManager: storage,
4040
matching: combinedPredicate,
4141
sortedBy: [sortDescriptorByDate])

0 commit comments

Comments
 (0)