mirror of
https://github.com/yattee/yattee.git
synced 2025-11-16 06:58:43 +00:00
Fix main actor isolation warnings in HomeView
Wrap favoritesChanged.toggle() calls in MainActor.run blocks to ensure main actor-isolated state mutations happen on the correct actor context. This resolves Swift concurrency warnings when updating state from nonisolated async contexts.
This commit is contained in:
@@ -121,15 +121,19 @@ struct HomeView: View {
|
||||
updateTask = Task {
|
||||
async let favoritesUpdates: Void = {
|
||||
for await _ in Defaults.updates(.favorites) {
|
||||
favoritesChanged.toggle()
|
||||
await MainActor.run {
|
||||
favoritesChanged.toggle()
|
||||
}
|
||||
}
|
||||
}()
|
||||
async let widgetsUpdates: Void = {
|
||||
for await _ in Defaults.updates(.widgetsSettings) {
|
||||
favoritesChanged.toggle()
|
||||
await MainActor.run {
|
||||
favoritesChanged.toggle()
|
||||
}
|
||||
}
|
||||
}()
|
||||
_ = await (favoritesUpdates, widgetsUpdates)
|
||||
_ = await(favoritesUpdates, widgetsUpdates)
|
||||
}
|
||||
}
|
||||
.onDisappear {
|
||||
@@ -143,15 +147,19 @@ struct HomeView: View {
|
||||
updateTask = Task {
|
||||
async let favoritesUpdates: Void = {
|
||||
for await _ in Defaults.updates(.favorites) {
|
||||
favoritesChanged.toggle()
|
||||
await MainActor.run {
|
||||
favoritesChanged.toggle()
|
||||
}
|
||||
}
|
||||
}()
|
||||
async let widgetsUpdates: Void = {
|
||||
for await _ in Defaults.updates(.widgetsSettings) {
|
||||
favoritesChanged.toggle()
|
||||
await MainActor.run {
|
||||
favoritesChanged.toggle()
|
||||
}
|
||||
}
|
||||
}()
|
||||
_ = await (favoritesUpdates, widgetsUpdates)
|
||||
_ = await(favoritesUpdates, widgetsUpdates)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user