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"
|
||||
|
||||
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"
|
||||
SoundManager.shared.playStopSound()
|
||||
|
||||
if AXIsProcessTrusted() {
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
|
||||
CursorPaster.pasteAtCursor(text)
|
||||
}
|
||||
} else {
|
||||
messageLog += "Accessibility permissions not granted. Transcription not pasted automatically.\n"
|
||||
}
|
||||
|
||||
if isAutoCopyEnabled {
|
||||
@ -561,15 +557,11 @@ 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 {
|
||||
@ -646,4 +638,3 @@ private class TaskDelegate: NSObject, URLSessionTaskDelegate {
|
||||
extension Notification.Name {
|
||||
static let toggleMiniRecorder = Notification.Name("toggleMiniRecorder")
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user