Fix dead record button after mic permission denial
The watch app's permission-denied state was a computed property reading AVAudioApplication.shared.recordPermission — external state Observation cannot track — so after a denied prompt the UI never flipped to the 'Microphone access is off' screen and the record button silently did nothing. Store the denied flag as a tracked property instead, updated on every permission request. Also: log (instead of swallow) recorder start failures, drop phantom recordings when no file was written (the watch simulator has no audio input device), sweep orphaned metadata sidecars on reconcile, and add a DEBUG-only 'autorecord' launch argument for CLI-driven testing. Claude-Session: https://claude.ai/code/session_01GKfAiKiQKLDTmbiGva4FGE
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import Foundation
|
||||
import Observation
|
||||
import OSLog
|
||||
import SwiftUI
|
||||
|
||||
/// Composition root for the watch app. Owns the recorder and the transfer
|
||||
@@ -31,12 +32,21 @@ final class WatchAppServices {
|
||||
}
|
||||
}
|
||||
|
||||
private let logger = Logger(subsystem: "dev.rzen.indie.Notes.watchkitapp", category: "recording")
|
||||
|
||||
/// Request permission (once) then begin recording. A no-op if already
|
||||
/// recording or permission is refused.
|
||||
func startRecording() async {
|
||||
guard !recorder.isRecording else { return }
|
||||
guard await recorder.requestPermission() else { return }
|
||||
try? recorder.startRecording()
|
||||
guard await recorder.requestPermission() else {
|
||||
logger.warning("microphone permission refused")
|
||||
return
|
||||
}
|
||||
do {
|
||||
try recorder.startRecording()
|
||||
} catch {
|
||||
logger.error("could not start recording: \(error, privacy: .public)")
|
||||
}
|
||||
}
|
||||
|
||||
private func stopAndQueue() {
|
||||
|
||||
Reference in New Issue
Block a user