From 82f3464f5d6a6bb8230ebd5c3c5384c3d1b52162 Mon Sep 17 00:00:00 2001 From: Beingpax Date: Fri, 29 Aug 2025 19:03:31 +0545 Subject: [PATCH] Fix timer memory leak in ProgressAnimation --- VoiceInk/Views/Recorder/RecorderComponents.swift | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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 + } } }