polscm32 aka Marvout před 1 rokem
rodič
revize
d4c99e55a9

+ 2 - 2
FreeAPS/Sources/Modules/Stat/StatStateModel.swift

@@ -70,10 +70,10 @@ extension Stat {
                 propertiesToFetch: ["glucose", "objectID"]
                 propertiesToFetch: ["glucose", "objectID"]
             )
             )
 
 
-            guard let fetchedResults = results as? [GlucoseStored] else { return [] }
+            guard let fetchedResults = results as? [[String: Any]] else { return [] }
 
 
             return await context.perform {
             return await context.perform {
-                return fetchedResults.map(\.objectID)
+                return fetchedResults.compactMap { $0["objectID"] as? NSManagedObjectID }
             }
             }
         }
         }
 
 

+ 9 - 3
FreeAPS/Sources/Services/Calendar/CalendarManager.swift

@@ -170,10 +170,13 @@ final class BaseCalendarManager: CalendarManager, Injectable {
             key: "timestamp",
             key: "timestamp",
             ascending: false,
             ascending: false,
             fetchLimit: 1,
             fetchLimit: 1,
-            propertiesToFetch: ["timestamp", "cob", "iob"]
+            propertiesToFetch: ["timestamp", "cob", "iob", "objectID"]
         )
         )
+        
+        guard let fetchedResults = results as? [[String: Any]], !fetchedResults.isEmpty else { return nil }
+        
         return await backgroundContext.perform {
         return await backgroundContext.perform {
-            results.first.map(\.objectID)
+            return fetchedResults.first?["objectID"] as? NSManagedObjectID
         }
         }
     }
     }
 
 
@@ -185,8 +188,11 @@ final class BaseCalendarManager: CalendarManager, Injectable {
             key: "date",
             key: "date",
             ascending: false
             ascending: false
         )
         )
+        
+        guard let fetchedResults = results as? [GlucoseStored] else { return [] }
+        
         return await backgroundContext.perform {
         return await backgroundContext.perform {
-            return results.map(\.objectID)
+            return fetchedResults.map(\.objectID)
         }
         }
     }
     }