From 0522ca17cf06f4fc4edebe680833d14573d01941 Mon Sep 17 00:00:00 2001 From: Laurent Date: Fri, 14 Apr 2023 10:43:59 +0200 Subject: [PATCH] End previous live activity when launching a new timer --- LeCountdown/Conductor.swift | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/LeCountdown/Conductor.swift b/LeCountdown/Conductor.swift index 894d0ca..f29131c 100644 --- a/LeCountdown/Conductor.swift +++ b/LeCountdown/Conductor.swift @@ -137,7 +137,7 @@ class Conductor: ObservableObject { DispatchQueue.main.async { let countdownId = countdown.stringId - self._cleanupCurrentTimerIfNecessary(countdownId) + self._cleanupPreviousTimerIfNecessary(countdownId) do { let start = Date() @@ -171,11 +171,12 @@ class Conductor: ObservableObject { } } - fileprivate func _cleanupCurrentTimerIfNecessary(_ timerId: TimerID) { + fileprivate func _cleanupPreviousTimerIfNecessary(_ timerId: TimerID) { self.removeLiveTimer(id: timerId) if let player = self._delayedSoundPlayers[timerId] { player.stop() // release resources } + self._endLiveActivity(timerId: timerId) } func cancelCountdown(id: TimerID) {