Skip to content

Commit 228f144

Browse files
committed
Dismiss Analytics view when a notice is set
1 parent 7aa749f commit 228f144

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

WooCommerce/Classes/ViewRelated/Dashboard/Analytics Hub/AnalyticsHubView.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,10 @@ struct AnalyticsHubView: View {
109109
.edgesIgnoringSafeArea(.horizontal)
110110
.task {
111111
await viewModel.updateData()
112-
if viewModel.errorSelectingTimeRange {
113-
dismissWithNotice(notice)
114-
}
112+
}
113+
.onReceive(viewModel.$notice) { notice in
114+
guard let notice else { return }
115+
dismissWithNotice(notice)
115116
}
116117
}
117118
}

WooCommerce/Classes/ViewRelated/Dashboard/Analytics Hub/AnalyticsHubViewModel.swift

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,11 @@ final class AnalyticsHubViewModel: ObservableObject {
4747
///
4848
@Published var timeRangeCard: AnalyticsTimeRangeCardViewModel
4949

50-
/// Defines the current notice that should be shown.
50+
/// Defines a notice that should be shown after the view is dismissed.
5151
/// Defaults to `nil`.
5252
///
5353
@Published var notice: Notice?
5454

55-
/// Whether selecting a time range failed
56-
///
57-
@Published private(set) var errorSelectingTimeRange: Bool = false
58-
5955
// MARK: Private data
6056

6157
/// Order stats for the current selected time period
@@ -82,7 +78,6 @@ final class AnalyticsHubViewModel: ObservableObject {
8278
try await retrieveOrderStats()
8379
} catch is AnalyticsHubTimeRangeSelection.TimeRangeGeneratorError {
8480
notice = Notice(title: Localization.timeRangeGeneratorError, feedbackType: .error)
85-
errorSelectingTimeRange = true
8681
DDLogWarn("⚠️ Error selecting analytics time range: \(timeRangeSelectionType.description)")
8782
} catch {
8883
switchToErrorState()

0 commit comments

Comments
 (0)