Ivan Valkou 5 лет назад
Родитель
Сommit
9dc267059a

+ 5 - 1
FreeAPS/Sources/Modules/Home/HomeViewModel.swift

@@ -182,7 +182,11 @@ extension Home {
                 self.suspensions = self.provider.pumpHistory(hours: self.filteredHours).filter {
                     $0.type == .pumpSuspend || $0.type == .pumpResume
                 }
-                self.pumpSuspended = self.suspensions.last?.type == .pumpSuspend
+
+                let last = self.suspensions.last
+                let tbr = self.tempBasals.first { $0.timestamp > (last?.timestamp ?? .distantPast) }
+
+                self.pumpSuspended = tbr == nil && last?.type == .pumpSuspend
             }
         }
 

+ 6 - 1
FreeAPS/Sources/Modules/Home/View/Chart/MainChartView.swift

@@ -546,8 +546,13 @@ extension MainChartView {
 
             let lastRec = self.suspensions.last.flatMap { event -> CGRect? in
                 guard event.type == .pumpSuspend else { return nil }
+                let tbrTimeX = self.tempBasals.first { $0.timestamp > event.timestamp }
+                    .map { self.timeToXCoordinate($0.timestamp.timeIntervalSince1970, fullSize: fullSize) }
                 let x0 = self.timeToXCoordinate(event.timestamp.timeIntervalSince1970, fullSize: fullSize)
-                let x1 = self.fullGlucoseWidth(viewWidth: fullSize.width) + self.additionalWidth(viewWidth: fullSize.width)
+
+                let x1 = tbrTimeX ?? self.fullGlucoseWidth(viewWidth: fullSize.width) + self
+                    .additionalWidth(viewWidth: fullSize.width)
+
                 return CGRect(x: x0, y: 0, width: x1 - x0, height: Config.basalHeight)
             }
             rects.append(firstRec)