mirror of
https://github.com/yattee/yattee.git
synced 2025-12-07 08:38:14 +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 {
|
updateTask = Task {
|
||||||
async let favoritesUpdates: Void = {
|
async let favoritesUpdates: Void = {
|
||||||
for await _ in Defaults.updates(.favorites) {
|
for await _ in Defaults.updates(.favorites) {
|
||||||
favoritesChanged.toggle()
|
await MainActor.run {
|
||||||
|
favoritesChanged.toggle()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
async let widgetsUpdates: Void = {
|
async let widgetsUpdates: Void = {
|
||||||
for await _ in Defaults.updates(.widgetsSettings) {
|
for await _ in Defaults.updates(.widgetsSettings) {
|
||||||
favoritesChanged.toggle()
|
await MainActor.run {
|
||||||
|
favoritesChanged.toggle()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
_ = await (favoritesUpdates, widgetsUpdates)
|
_ = await(favoritesUpdates, widgetsUpdates)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.onDisappear {
|
.onDisappear {
|
||||||
@@ -143,15 +147,19 @@ struct HomeView: View {
|
|||||||
updateTask = Task {
|
updateTask = Task {
|
||||||
async let favoritesUpdates: Void = {
|
async let favoritesUpdates: Void = {
|
||||||
for await _ in Defaults.updates(.favorites) {
|
for await _ in Defaults.updates(.favorites) {
|
||||||
favoritesChanged.toggle()
|
await MainActor.run {
|
||||||
|
favoritesChanged.toggle()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
async let widgetsUpdates: Void = {
|
async let widgetsUpdates: Void = {
|
||||||
for await _ in Defaults.updates(.widgetsSettings) {
|
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