diff --git a/VoiceInk/Views/Recorder/RecorderComponents.swift b/VoiceInk/Views/Recorder/RecorderComponents.swift index 7956f1c..6d8104c 100644 --- a/VoiceInk/Views/Recorder/RecorderComponents.swift +++ b/VoiceInk/Views/Recorder/RecorderComponents.swift @@ -121,6 +121,7 @@ struct ProcessingIndicator: View { // MARK: - Progress Animation Component struct ProgressAnimation: View { @State private var currentDot = 0 + @State private var timer: Timer? let animationSpeed: Double var body: some View { @@ -132,11 +133,15 @@ struct ProgressAnimation: View { } } .onAppear { - Timer.scheduledTimer(withTimeInterval: animationSpeed, repeats: true) { _ in + timer = Timer.scheduledTimer(withTimeInterval: animationSpeed, repeats: true) { _ in currentDot = (currentDot + 1) % 7 if currentDot >= 5 { currentDot = -1 } } } + .onDisappear { + timer?.invalidate() + timer = nil + } } }