Update WhisperState.swift
This commit is contained in:
parent
f33de6b5a8
commit
61453740cd
@ -386,18 +386,14 @@ class WhisperState: NSObject, ObservableObject, AVAudioRecorderDelegate {
|
|||||||
|
|
||||||
messageLog += "Done: \(text)\n"
|
messageLog += "Done: \(text)\n"
|
||||||
|
|
||||||
if !shouldCancelRecording {
|
SoundManager.shared.playStopSound()
|
||||||
SoundManager.shared.playStopSound()
|
|
||||||
|
if AXIsProcessTrusted() {
|
||||||
if AXIsProcessTrusted() {
|
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
|
||||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
|
CursorPaster.pasteAtCursor(text)
|
||||||
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 {
|
if isAutoCopyEnabled {
|
||||||
@ -561,15 +557,11 @@ class WhisperState: NSObject, ObservableObject, AVAudioRecorderDelegate {
|
|||||||
isTranscribing = false
|
isTranscribing = false
|
||||||
canTranscribe = true
|
canTranscribe = true
|
||||||
isMiniRecorderVisible = false
|
isMiniRecorderVisible = false
|
||||||
|
shouldCancelRecording = false
|
||||||
}
|
}
|
||||||
|
|
||||||
try? await Task.sleep(nanoseconds: 150_000_000)
|
try? await Task.sleep(nanoseconds: 150_000_000)
|
||||||
await cleanupResources()
|
await cleanupResources()
|
||||||
|
|
||||||
// Reset cancellation flag only after all cleanup is done
|
|
||||||
await MainActor.run {
|
|
||||||
shouldCancelRecording = false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func cancelRecording() async {
|
func cancelRecording() async {
|
||||||
@ -646,4 +638,3 @@ private class TaskDelegate: NSObject, URLSessionTaskDelegate {
|
|||||||
extension Notification.Name {
|
extension Notification.Name {
|
||||||
static let toggleMiniRecorder = Notification.Name("toggleMiniRecorder")
|
static let toggleMiniRecorder = Notification.Name("toggleMiniRecorder")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user