You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: InfiniLink/Core/StepsView.swift
+7Lines changed: 7 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -66,6 +66,13 @@ struct StepsView: View {
66
66
.alert(isPresented: $showInfoAlert){
67
67
Alert(title:Text("Steps Per Minute"), message:Text("SPM stands for steps per minute and measures how many steps you take for each minute of walking."), dismissButton:.default(Text("OK")))
@@ -32,28 +35,34 @@ class StepCountManager: ObservableObject {
32
35
}
33
36
}
34
37
35
-
privatefunc updateStepCount(_ stepCount:StepCounts, with steps:Int32, isArbitrary:Bool, for date:Date){
36
-
if isArbitrary {
37
-
stepCount.steps += steps
38
+
privatefunc updateStepCount(_ current:StepCounts, with steps:Int32, isArbitrary:Bool, for date:Date){
39
+
// Last saved step count is current.steps = 978
40
+
// We just received steps = 0
41
+
if addInsteadOfOverwrite {
42
+
// We have to do some math here because otherwise we'll just double the value
43
+
if steps <= current.steps { // The watch reset, so add the new steps to the old count
44
+
// This is fairly accurate, although about 6 steps get added because the watch tracks around that many before it sends the count (before we can set current.previousSteps)
0 commit comments