Skip to content

Commit c103fa2

Browse files
authored
Merge pull request #302 from ejensen/store-info-concurrency-warning
Fix concurrency issue in `StoreDetailsViewModel`
2 parents e93c47b + 279b85b commit c103fa2

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

Sources/PulseUI/Features/Settings/StoreDetailsView.swift

+4-6
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ struct StoreDetailsView: View {
1313

1414
var body: some View {
1515
StoreDetailsContentsView(viewModel: viewModel)
16-
.onAppear { viewModel.load(from: source) }
16+
.task { await viewModel.load(from: source) }
1717
#if os(tvOS)
1818
.padding()
1919
#else
@@ -97,18 +97,16 @@ enum StoreDetailsViewSource {
9797

9898
// MARK: - ViewModel
9999

100-
final class StoreDetailsViewModel: ObservableObject {
100+
@MainActor final class StoreDetailsViewModel: ObservableObject {
101101
@Published private(set) var storeSizeLimit: Int64?
102102
@Published private(set) var sections: [KeyValueSectionViewModel] = []
103103
@Published private(set) var info: LoggerStore.Info?
104104
@Published private(set) var errorMessage: String?
105105

106-
func load(from source: StoreDetailsViewSource) {
106+
func load(from source: StoreDetailsViewSource) async {
107107
switch source {
108108
case .store(let store):
109-
Task {
110-
await loadInfo(for: store)
111-
}
109+
await loadInfo(for: store)
112110
case .info(let value):
113111
display(value)
114112
}

0 commit comments

Comments
 (0)