Avoid publishing VoiceRecordingViewModel.state during SwiftUI alert updates

This commit is contained in:
jack committed 2026-11-28 01:15:27 -10:00
1 parent fec56edf43
commit 3e5310a457
3 files changed
+11 -3

No files matched your search

@@ -59,7 +59,8 @@ final class VoiceRecordingViewModel: ObservableObject {
}
}
set {
if !newValue { state = .idle }
guard !newValue, showAlert else { return }
state = .idle
}
}
+3 -1
View File
@@ -107,7 +107,9 @@ struct ContentPeopleSheetView: View {
!hasModalPresentationBesidesVoiceAlert else {
return
}
voiceRecordingVM.showAlert = false
Task { @MainActor in
voiceRecordingVM.showAlert = false
}
}
)
}
+6 -1
View File
@@ -226,7 +226,12 @@ struct WalkieTalkieSheetView: View {
Text(String(localized: "voice.error.title", defaultValue: "Recording error", comment: "Title of the voice recording error alert")),
isPresented: Binding(
get: { voiceRecordingVM.showAlert },
set: { if !$0 { voiceRecordingVM.showAlert = false } }
set: { isPresented in
guard !isPresented, voiceRecordingVM.showAlert else { return }
Task { @MainActor in
voiceRecordingVM.showAlert = false
}
}
),
actions: {
Button(String(localized: "common.ok"), role: .cancel) {}