Skip to content

Commit

Permalink
Prevent mutating @Published StoreDetailsViewModel values on backgro…
Browse files Browse the repository at this point in the history
…und queues
  • Loading branch information
ejensen committed Oct 9, 2024
1 parent efac97a commit 279b85b
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 279b85b

Please sign in to comment.