-
Notifications
You must be signed in to change notification settings - Fork 121
[Booking] Fix empty state after reload #16417
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
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -5,6 +5,10 @@ import Combine | |||||||||||||||
| import protocol Storage.StorageManagerType | ||||||||||||||||
| import class Networking.BookingsRemote | ||||||||||||||||
|
|
||||||||||||||||
| protocol BookingListsRefreshCoordinating: AnyObject { | ||||||||||||||||
| func refreshAllLists() async | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| /// View model for `BookingListView` | ||||||||||||||||
| final class BookingListViewModel: ObservableObject { | ||||||||||||||||
|
|
||||||||||||||||
|
|
@@ -14,6 +18,8 @@ final class BookingListViewModel: ObservableObject { | |||||||||||||||
|
|
||||||||||||||||
| @Published private(set) var hasFilters = false | ||||||||||||||||
|
|
||||||||||||||||
| weak var refreshCoordinator: BookingListsRefreshCoordinating? | ||||||||||||||||
|
|
||||||||||||||||
| var emptyStateTitle: String { | ||||||||||||||||
| type.emptyStateTitle(hasFilters: hasFilters) | ||||||||||||||||
| } | ||||||||||||||||
|
|
@@ -32,6 +38,7 @@ final class BookingListViewModel: ObservableObject { | |||||||||||||||
|
|
||||||||||||||||
| private static let refreshCacheReason = "refresh-cache" | ||||||||||||||||
| private static let reorderReason = "reorder" | ||||||||||||||||
| static let siblingRefreshReason = "sibling-refresh" | ||||||||||||||||
|
|
||||||||||||||||
| /// Keeps track of the current state of the syncing | ||||||||||||||||
| @Published private(set) var syncState: SyncState = .empty | ||||||||||||||||
|
|
@@ -58,6 +65,7 @@ final class BookingListViewModel: ObservableObject { | |||||||||||||||
|
|
||||||||||||||||
| init(siteID: Int64, | ||||||||||||||||
| type: BookingListTab, | ||||||||||||||||
| parent: BookingListContainerViewModel? = nil, | ||||||||||||||||
| stores: StoresManager = ServiceLocator.stores, | ||||||||||||||||
| storage: StorageManagerType = ServiceLocator.storageManager, | ||||||||||||||||
| currentDate: Date = Date()) { | ||||||||||||||||
|
|
@@ -96,10 +104,14 @@ final class BookingListViewModel: ObservableObject { | |||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| /// Called when the user pulls down the list to refresh. | ||||||||||||||||
| @MainActor | ||||||||||||||||
| func onRefreshAction() async { | ||||||||||||||||
| await refreshCoordinator?.refreshAllLists() | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| @MainActor | ||||||||||||||||
| func onRefreshSelfAction(reason: String? = nil) async { | ||||||||||||||||
| await withCheckedContinuation { continuation in | ||||||||||||||||
| paginationTracker.resync(reason: Self.refreshCacheReason) { | ||||||||||||||||
| paginationTracker.resync(reason: reason ?? Self.refreshCacheReason) { | ||||||||||||||||
|
||||||||||||||||
| func onRefreshSelfAction(reason: String? = nil) async { | |
| await withCheckedContinuation { continuation in | |
| paginationTracker.resync(reason: Self.refreshCacheReason) { | |
| paginationTracker.resync(reason: reason ?? Self.refreshCacheReason) { | |
| func reloadData(reason: String = Self.refreshCacheReason) async { | |
| await withCheckedContinuation { continuation in | |
| paginationTracker.resync(reason: reason) { |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -59,7 +59,7 @@ final class BookingSearchViewModel: ObservableObject { | |
|
|
||
| /// Called when the user pulls down the list to refresh. | ||
| @MainActor | ||
| func onRefreshAction() async { | ||
| func onRefreshAction(reason: String? = nil) async { | ||
|
||
| await withCheckedContinuation { continuation in | ||
| searchPaginationTracker.resync(reason: nil) { | ||
| continuation.resume(returning: ()) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious: why is this necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not needed at all! I was just fiddling around with the tabs, and I guess I haven't fully reverted one of my changes. I'll remove the returns.