This commit is contained in:
Trey t
2023-06-25 22:05:00 -05:00
parent f40c40c9bb
commit 57cc5e3ce5
2 changed files with 17 additions and 15 deletions

View File

@@ -93,15 +93,17 @@ class BridgeModule: NSObject, ObservableObject {
}
private func startTimerWith(duration: Int) {
timer?.invalidate()
timer = nil
timeLeft = duration
timer = Timer.scheduledTimer(timeInterval: 1,
target: self,
selector: #selector(updateCounter),
userInfo: nil,
repeats: true)
timer?.fire()
DispatchQueue.main.async {
self.timer?.invalidate()
self.timer = nil
self.timeLeft = duration
self.timer = Timer.scheduledTimer(timeInterval: 1,
target: self,
selector: #selector(self.updateCounter),
userInfo: nil,
repeats: true)
self.timer?.fire()
}
}
@objc func updateCounter() {
@@ -137,10 +139,12 @@ class BridgeModule: NSObject, ObservableObject {
}
func updateCurrent(exercise: ExerciseElement) {
self.currentExercise = exercise
if let duration = exercise.duration {
startTimerWith(duration: duration)
DispatchQueue.main.async {
self.currentExercise = exercise
if let duration = exercise.duration {
self.startTimerWith(duration: duration)
}
}
}
}

View File

@@ -81,8 +81,6 @@ struct AllWorkoutsView: View {
fatalError("shit broke")
}
})
} else {
fatalError("shit broke")
}
} else {
showLoginView = true