Преглед изворни кода

Minutes ago fix for G7 sensors.

(cherry picked from commit 0605328a02dd4598770fadafff4f566b6b8f5174)
Jon Mårtensson пре 2 година
родитељ
комит
1bea3baca4

+ 3 - 3
FreeAPS/Sources/Modules/Home/View/Header/CurrentGlucoseView.swift

@@ -59,10 +59,10 @@ struct CurrentGlucoseView: View {
                 image
             }
             HStack {
-                let minutes = (recentGlucose?.dateString.timeIntervalSinceNow ?? 0) / 60
-                let text = timaAgoFormatter.string(for: Double(minutes)) ?? ""
+                let minutesAgo = -1 * (recentGlucose?.dateString.timeIntervalSinceNow ?? 0) / 60
+                let text = timaAgoFormatter.string(for: Double(minutesAgo)) ?? ""
                 Text(
-                    text == "0" ? "< 1 " + NSLocalizedString("min", comment: "Short form for minutes") : (
+                    minutesAgo <= 1 ? "< 1 " + NSLocalizedString("min", comment: "Short form for minutes") : (
                         text + " " +
                             NSLocalizedString("min", comment: "Short form for minutes") + " "
                     )

+ 2 - 2
FreeAPS/Sources/Shortcuts/State/ListStateView.swift

@@ -76,10 +76,10 @@ struct ListStateView: View {
                 image
             }
             HStack {
-                let minutes = state.date.timeIntervalSinceNow / 60
+                let minutes = -1 * state.date.timeIntervalSinceNow / 60
                 let text = timaAgoFormatter.string(for: Double(minutes)) ?? ""
                 Text(
-                    text == "0" ? "< 1 " + NSLocalizedString("min", comment: "Short form for minutes") : (
+                    minutes <= 1 ? "< 1 " + NSLocalizedString("min", comment: "Short form for minutes") : (
                         text + " " +
                             NSLocalizedString("min", comment: "Short form for minutes") + " "
                     )