Ver código fonte

TidePool implementation : Add force upload

Add a function to force all uploads in TidePool
Call this function when close the windows "TidePool" config

(cherry picked from commit d59df1a878849d2b987d797502c98c614c17044a)
Pierre L 2 anos atrás
pai
commit
270370154e

+ 2 - 0
FreeAPS/Sources/Modules/Settings/SettingsStateModel.swift

@@ -8,6 +8,7 @@ extension Settings {
         @Injected() private var fileManager: FileManager!
         @Injected() private var nightscoutManager: NightscoutManager!
         @Injected() var pluginManager: PluginManager!
+        @Injected() var fetchCgmManager: FetchGlucoseManager!
 
         @Published var closedLoop = false
         @Published var debugOptions = false
@@ -105,5 +106,6 @@ extension Settings.StateModel: ServiceOnboardingDelegate {
 extension Settings.StateModel: CompletionDelegate {
     func completionNotifyingDidComplete(_: CompletionNotifying) {
         setupTidePool = false
+        provider.tidePoolManager.forceUploadData(device: fetchCgmManager.cgmManager?.cgmManagerStatus.device)
     }
 }

+ 8 - 0
FreeAPS/Sources/Services/Network/TidepoolManager.swift

@@ -13,6 +13,7 @@ protocol TidePoolManager {
     func deleteInsulin(at date: Date)
 //    func uploadStatus()
     func uploadGlucose(device: HKDevice?)
+    func forceUploadData(device: HKDevice?)
 //    func uploadStatistics(dailystat: Statistics)
 //    func uploadPreferences(_ preferences: Preferences)
 //    func uploadProfileAndSettings(_: Bool)
@@ -344,6 +345,13 @@ final class BaseTidePoolManager: TidePoolManager, Injectable {
                 }
         }
     }
+
+    /// force to uploads all data in TidePool Service
+    func forceUploadData(device: HKDevice?) {
+        uploadDose()
+        uploadCarbs()
+        uploadGlucose(device: device)
+    }
 }
 
 extension BaseTidePoolManager: PumpHistoryObserver {