Skip to content

Commit

Permalink
Merge pull request #302 from ejensen/store-info-concurrency-warning
Browse files Browse the repository at this point in the history
Fix concurrency issue in `StoreDetailsViewModel`
  • Loading branch information
kean authored Oct 10, 2024
2 parents e93c47b + 279b85b commit c103fa2
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions Sources/PulseUI/Features/Settings/StoreDetailsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ struct StoreDetailsView: View {

var body: some View {
StoreDetailsContentsView(viewModel: viewModel)
.onAppear { viewModel.load(from: source) }
.task { await viewModel.load(from: source) }
#if os(tvOS)
.padding()
#else
Expand Down Expand Up @@ -97,18 +97,16 @@ enum StoreDetailsViewSource {

// MARK: - ViewModel

final class StoreDetailsViewModel: ObservableObject {
@MainActor final class StoreDetailsViewModel: ObservableObject {
@Published private(set) var storeSizeLimit: Int64?
@Published private(set) var sections: [KeyValueSectionViewModel] = []
@Published private(set) var info: LoggerStore.Info?
@Published private(set) var errorMessage: String?

func load(from source: StoreDetailsViewSource) {
func load(from source: StoreDetailsViewSource) async {
switch source {
case .store(let store):
Task {
await loadInfo(for: store)
}
await loadInfo(for: store)
case .info(let value):
display(value)
}
Expand Down

0 comments on commit c103fa2

Please sign in to comment.