fix: maintain cancellation state until cleanup is complete to prevent unwanted sound playback
This commit is contained in:
parent
9173264407
commit
f33de6b5a8
@ -48,4 +48,4 @@ class CursorPaster {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -57,7 +57,7 @@ struct LicenseManagementView: View {
|
||||
if case .licensed = licenseViewModel.licenseState {
|
||||
HStack(spacing: 40) {
|
||||
Button {
|
||||
if let url = URL(string: "https://voiceink.featurebase.app/changelog") {
|
||||
if let url = URL(string: "https://github.com/Beingpax/VoiceInk/releases") {
|
||||
NSWorkspace.shared.open(url)
|
||||
}
|
||||
} label: {
|
||||
@ -84,7 +84,7 @@ struct LicenseManagementView: View {
|
||||
.buttonStyle(.plain)
|
||||
|
||||
Button {
|
||||
if let url = URL(string: "https://voiceink.featurebase.app") {
|
||||
if let url = URL(string: "https://github.com/Beingpax/VoiceInk/issues") {
|
||||
NSWorkspace.shared.open(url)
|
||||
}
|
||||
} label: {
|
||||
|
||||
@ -386,14 +386,18 @@ class WhisperState: NSObject, ObservableObject, AVAudioRecorderDelegate {
|
||||
|
||||
messageLog += "Done: \(text)\n"
|
||||
|
||||
SoundManager.shared.playStopSound()
|
||||
|
||||
if AXIsProcessTrusted() {
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
|
||||
CursorPaster.pasteAtCursor(text)
|
||||
if !shouldCancelRecording {
|
||||
SoundManager.shared.playStopSound()
|
||||
|
||||
if AXIsProcessTrusted() {
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
|
||||
if !self.shouldCancelRecording {
|
||||
CursorPaster.pasteAtCursor(text)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
messageLog += "Accessibility permissions not granted. Transcription not pasted automatically.\n"
|
||||
}
|
||||
} else {
|
||||
messageLog += "Accessibility permissions not granted. Transcription not pasted automatically.\n"
|
||||
}
|
||||
|
||||
if isAutoCopyEnabled {
|
||||
@ -557,11 +561,15 @@ class WhisperState: NSObject, ObservableObject, AVAudioRecorderDelegate {
|
||||
isTranscribing = false
|
||||
canTranscribe = true
|
||||
isMiniRecorderVisible = false
|
||||
shouldCancelRecording = false
|
||||
}
|
||||
|
||||
try? await Task.sleep(nanoseconds: 150_000_000)
|
||||
await cleanupResources()
|
||||
|
||||
// Reset cancellation flag only after all cleanup is done
|
||||
await MainActor.run {
|
||||
shouldCancelRecording = false
|
||||
}
|
||||
}
|
||||
|
||||
func cancelRecording() async {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user