ソースを参照

Minor adjustmnets

Deniz Cengiz 1 年間 前
コミット
3e9b9ae39c

+ 8 - 6
Trio Watch App Extension/Views/TrendShape.swift

@@ -157,25 +157,26 @@ struct TrendShape: View {
 }
 }
 
 
 // MARK: - TREND SHAPE PREVIEWS
 // MARK: - TREND SHAPE PREVIEWS
+
 struct TrendShape_Previews: PreviewProvider {
 struct TrendShape_Previews: PreviewProvider {
     static var previews: some View {
     static var previews: some View {
         Group {
         Group {
-            TrendShape(rotationDegrees: 0,  deviceType: .watch40mm)
+            TrendShape(rotationDegrees: 0, deviceType: .watch40mm)
                 .previewDisplayName("TrendShape • 40mm")
                 .previewDisplayName("TrendShape • 40mm")
 
 
-            TrendShape(rotationDegrees: 0,  deviceType: .watch41mm)
+            TrendShape(rotationDegrees: 0, deviceType: .watch41mm)
                 .previewDisplayName("TrendShape • 41mm")
                 .previewDisplayName("TrendShape • 41mm")
 
 
-            TrendShape(rotationDegrees: 0,  deviceType: .watch42mm)
+            TrendShape(rotationDegrees: 0, deviceType: .watch42mm)
                 .previewDisplayName("TrendShape • 42mm")
                 .previewDisplayName("TrendShape • 42mm")
 
 
-            TrendShape(rotationDegrees: 0,  deviceType: .watch44mm)
+            TrendShape(rotationDegrees: 0, deviceType: .watch44mm)
                 .previewDisplayName("TrendShape • 44mm")
                 .previewDisplayName("TrendShape • 44mm")
 
 
-            TrendShape(rotationDegrees: 0,  deviceType: .watch45mm)
+            TrendShape(rotationDegrees: 0, deviceType: .watch45mm)
                 .previewDisplayName("TrendShape • 45mm")
                 .previewDisplayName("TrendShape • 45mm")
 
 
-            TrendShape(rotationDegrees: 0,  deviceType: .watch49mm)
+            TrendShape(rotationDegrees: 0, deviceType: .watch49mm)
                 .previewDisplayName("TrendShape • 49mm")
                 .previewDisplayName("TrendShape • 49mm")
         }
         }
         .padding()
         .padding()
@@ -185,6 +186,7 @@ struct TrendShape_Previews: PreviewProvider {
 }
 }
 
 
 // MARK: - TRIANGLE PREVIEWS
 // MARK: - TRIANGLE PREVIEWS
+
 struct Triangle_Previews: PreviewProvider {
 struct Triangle_Previews: PreviewProvider {
     static var previews: some View {
     static var previews: some View {
         Group {
         Group {

+ 10 - 6
Trio/Sources/Services/WatchManager/AppleWatchManager.swift

@@ -99,12 +99,7 @@ final class BaseWatchManager: NSObject, WCSessionDelegate, Injectable, WatchMana
         coreDataPublisher?.filterByEntityName("PumpEventStored").sink { [weak self] _ in
         coreDataPublisher?.filterByEntityName("PumpEventStored").sink { [weak self] _ in
             guard let self = self else { return }
             guard let self = self else { return }
             Task {
             Task {
-                if let lastBolusObjectId = await self.fetchLastBolus() {
-                    let lastBolusObject: [PumpEventStored] = await CoreDataStack.shared
-                        .getNSManagedObject(with: [lastBolusObjectId], context: self.backgroundContext)
-
-                    self.activeBolusAmount = lastBolusObject.first?.bolus?.amount?.doubleValue ?? 0.0
-                }
+                await self.getActiveBolusAmount()
             }
             }
         }.store(in: &subscriptions)
         }.store(in: &subscriptions)
 
 
@@ -336,6 +331,15 @@ final class BaseWatchManager: NSObject, WCSessionDelegate, Injectable, WatchMana
         }
         }
     }
     }
 
 
+    /// Gets the active bolus amount by fetching last (active) bolus.
+    @MainActor func getActiveBolusAmount() async {
+        if let lastBolusObjectId = await self.fetchLastBolus() {
+            let lastBolusObject: [PumpEventStored] = await CoreDataStack.shared
+                .getNSManagedObject(with: [lastBolusObjectId], context: self.backgroundContext)
+            
+            self.activeBolusAmount = lastBolusObject.first?.bolus?.amount?.doubleValue ?? 0.0
+        }
+    }
     // MARK: - Send to Watch
     // MARK: - Send to Watch
 
 
     /// Sends the state of type WatchState to the connected Watch
     /// Sends the state of type WatchState to the connected Watch