Przeglądaj źródła

Merge branch 'core-data-sync-trio' of github.com:dnzxy/Trio-dev into watch

polscm32 aka Marvout 1 rok temu
rodzic
commit
11a69af4b4

+ 7 - 8
Trio/Sources/APS/APSManager.swift

@@ -130,7 +130,7 @@ final class BaseAPSManager: APSManager, Injectable {
             let wasParsed = storage.parseOnFileSettingsToMgdL()
             if wasParsed {
                 Task {
-                    await openAPS.createInitialProfiles()
+                    await openAPS.createProfiles()
                 }
             }
         }
@@ -385,14 +385,13 @@ final class BaseAPSManager: APSManager, Injectable {
         do {
             let now = Date()
 
-            // Start fetching asynchronously
-            let (currentTemp, _) = try await (
-                fetchCurrentTempBasal(date: now),
-                autosense()
-            )
+            // Parallelize the fetches using async let
+            async let currentTemp = fetchCurrentTempBasal(date: now)
+            async let autosenseResult = autosense()
 
-            // Determine basal using the fetched temp and current time
-            let determination = try await openAPS.determineBasal(currentTemp: currentTemp, clock: now)
+            _ = try await autosenseResult
+            await openAPS.createProfiles()
+            let determination = try await openAPS.determineBasal(currentTemp: await currentTemp, clock: now)
 
             if let determination = determination {
                 DispatchQueue.main.async {

+ 1 - 1
Trio/Sources/APS/OpenAPS/OpenAPS.swift

@@ -462,7 +462,7 @@ final class OpenAPS {
         }
     }
 
-    func createInitialProfiles() async {
+    func createProfiles() async {
         debug(.openAPS, "Start creating pump profile and user profile")
 
         // Load required settings and profiles asynchronously