Forráskód Böngészése

Force push Profiles and settings when using button

Jon Mårtensson 2 éve
szülő
commit
4a39fba439

+ 3 - 3
FreeAPS/Sources/Modules/Settings/SettingsStateModel.swift

@@ -46,13 +46,13 @@ extension Settings {
             return items
             return items
         }
         }
 
 
-        func uploadProfileAndSettings() {
+        func uploadProfileAndSettings(_: Bool) {
             NSLog("SettingsState Upload Profile")
             NSLog("SettingsState Upload Profile")
-            nightscoutManager.uploadProfileAndSettings()
+            nightscoutManager.uploadProfileAndSettings(true)
         }
         }
 
 
         func hideSettingsModal() {
         func hideSettingsModal() {
-            nightscoutManager.uploadProfileAndSettings()
+            nightscoutManager.uploadProfileAndSettings(false)
             hideModal()
             hideModal()
         }
         }
     }
     }

+ 1 - 1
FreeAPS/Sources/Modules/Settings/View/SettingsRootView.swift

@@ -51,7 +51,7 @@ extension Settings {
                         Group {
                         Group {
                             HStack {
                             HStack {
                                 Text("NS Upload Profile and Settings")
                                 Text("NS Upload Profile and Settings")
-                                Button("Upload") { state.uploadProfileAndSettings() }
+                                Button("Upload") { state.uploadProfileAndSettings(true) }
                                     .frame(maxWidth: .infinity, alignment: .trailing)
                                     .frame(maxWidth: .infinity, alignment: .trailing)
                                     .buttonStyle(.borderedProminent)
                                     .buttonStyle(.borderedProminent)
                             }
                             }

+ 6 - 6
FreeAPS/Sources/Services/Network/NightscoutManager.swift

@@ -17,7 +17,7 @@ protocol NightscoutManager: GlucoseSource {
     func uploadManualGlucose()
     func uploadManualGlucose()
     func uploadStatistics(dailystat: Statistics)
     func uploadStatistics(dailystat: Statistics)
     func uploadPreferences(_ preferences: Preferences)
     func uploadPreferences(_ preferences: Preferences)
-    func uploadProfileAndSettings()
+    func uploadProfileAndSettings(_: Bool)
     var cgmURL: URL? { get }
     var cgmURL: URL? { get }
 }
 }
 
 
@@ -445,7 +445,7 @@ final class BaseNightscoutManager: NightscoutManager, Injectable {
         }
         }
     }
     }
 
 
-    func uploadProfileAndSettings() {
+    func uploadProfileAndSettings(_ force: Bool) {
         // These should be modified anyways and not the defaults
         // These should be modified anyways and not the defaults
         guard let sensitivities = storage.retrieve(OpenAPS.Settings.insulinSensitivities, as: InsulinSensitivities.self),
         guard let sensitivities = storage.retrieve(OpenAPS.Settings.insulinSensitivities, as: InsulinSensitivities.self),
               let basalProfile = storage.retrieve(OpenAPS.Settings.basalProfile, as: [BasalProfileEntry].self),
               let basalProfile = storage.retrieve(OpenAPS.Settings.basalProfile, as: [BasalProfileEntry].self),
@@ -454,7 +454,7 @@ final class BaseNightscoutManager: NightscoutManager, Injectable {
               let preferences = storage.retrieve(OpenAPS.Settings.preferences, as: Preferences.self),
               let preferences = storage.retrieve(OpenAPS.Settings.preferences, as: Preferences.self),
               let settings = storage.retrieve(OpenAPS.FreeAPS.settings, as: FreeAPSSettings.self)
               let settings = storage.retrieve(OpenAPS.FreeAPS.settings, as: FreeAPSSettings.self)
         else {
         else {
-            NSLog("NightscoutManager uploadProfile Not all settings found to build profile!")
+            debug(.nightscout, "NightscoutManager uploadProfile Not all settings found to build profile!")
             return
             return
         }
         }
 
 
@@ -548,20 +548,20 @@ final class BaseNightscoutManager: NightscoutManager, Injectable {
 
 
         // UPLOAD PREFERNCES WHEN CHANGED
         // UPLOAD PREFERNCES WHEN CHANGED
         if let uploadedPreferences = storage.retrieve(OpenAPS.Nightscout.uploadedPreferences, as: Preferences.self),
         if let uploadedPreferences = storage.retrieve(OpenAPS.Nightscout.uploadedPreferences, as: Preferences.self),
-           uploadedPreferences.rawJSON.sorted() == preferences.rawJSON.sorted()
+           uploadedPreferences.rawJSON.sorted() == preferences.rawJSON.sorted(), !force
         {
         {
             NSLog("NightscoutManager Preferences, preferences unchanged")
             NSLog("NightscoutManager Preferences, preferences unchanged")
         } else { uploadPreferences(preferences) }
         } else { uploadPreferences(preferences) }
 
 
         // UPLOAD FreeAPS Settings WHEN CHANGED
         // UPLOAD FreeAPS Settings WHEN CHANGED
         if let uploadedSettings = storage.retrieve(OpenAPS.Nightscout.uploadedSettings, as: FreeAPSSettings.self),
         if let uploadedSettings = storage.retrieve(OpenAPS.Nightscout.uploadedSettings, as: FreeAPSSettings.self),
-           uploadedSettings.rawJSON.sorted() == settings.rawJSON.sorted()
+           uploadedSettings.rawJSON.sorted() == settings.rawJSON.sorted(), !force
         {
         {
             NSLog("NightscoutManager Settings, settings unchanged")
             NSLog("NightscoutManager Settings, settings unchanged")
         } else { uploadSettings(settings) }
         } else { uploadSettings(settings) }
 
 
         if let uploadedProfile = storage.retrieve(OpenAPS.Nightscout.uploadedProfile, as: NightscoutProfileStore.self),
         if let uploadedProfile = storage.retrieve(OpenAPS.Nightscout.uploadedProfile, as: NightscoutProfileStore.self),
-           (uploadedProfile.store["default"]?.rawJSON ?? "").sorted() == ps.rawJSON.sorted()
+           (uploadedProfile.store["default"]?.rawJSON ?? "").sorted() == ps.rawJSON.sorted(), !force
         {
         {
             NSLog("NightscoutManager uploadProfile, no profile change")
             NSLog("NightscoutManager uploadProfile, no profile change")
             return
             return