Bläddra i källkod

Allow to delete Carbs when connexion with NS is impossible - Alert the user of the issue. (#606)

Pierre L 3 år sedan
förälder
incheckning
b34bf0a692

+ 4 - 2
FreeAPS/Sources/Logger/Logger.swift

@@ -28,13 +28,14 @@ func debug(
 func info(
     _ category: Logger.Category,
     _ message: String,
+    type: MessageType = .info,
     file: String = #file,
     function: String = #function,
     line: UInt = #line
 ) {
     DispatchWorkItem(qos: .background, flags: .enforceQoS) {
         loggerLock.perform {
-            category.logger.info(message, file: file, function: function, line: line)
+            category.logger.info(message, type: type, file: file, function: function, line: line)
         }
     }.perform()
 }
@@ -220,6 +221,7 @@ final class Logger {
 
     func info(
         _ message: String,
+        type: MessageType = .info,
         file: String = #file,
         function: String = #function,
         line: UInt = #line
@@ -228,7 +230,7 @@ final class Logger {
         os_log("%@ - %@ - %d %{public}@", log: log, type: .info, file.file, function, line, printedMessage)
         reporter.log(category.name, printedMessage, file: file, function: function, line: line)
 
-        showAlert(message, type: .info)
+        showAlert(message, type: type)
     }
 
     func warning(

+ 11 - 3
FreeAPS/Sources/Services/Network/NightscoutManager.swift

@@ -201,10 +201,14 @@ final class BaseNightscoutManager: NightscoutManager, Injectable {
                     self.carbsStorage.deleteCarbs(at: date)
                     switch completion {
                     case .finished:
-                        self.carbsStorage.deleteCarbs(at: date)
                         debug(.nightscout, "Carbs deleted")
+
                     case let .failure(error):
-                        debug(.nightscout, error.localizedDescription)
+                        info(
+                            .nightscout,
+                            "Deletion of carbs in NightScout not done \n \(error.localizedDescription)",
+                            type: MessageType.warning
+                        )
                     }
                 } receiveValue: { _ in }
                 .store(in: &lifetime)
@@ -217,7 +221,11 @@ final class BaseNightscoutManager: NightscoutManager, Injectable {
                     case .finished:
                         debug(.nightscout, "Carbs deleted")
                     case let .failure(error):
-                        debug(.nightscout, error.localizedDescription)
+                        info(
+                            .nightscout,
+                            "Deletion of carbs in NightScout not done \n \(error.localizedDescription)",
+                            type: MessageType.warning
+                        )
                     }
                 } receiveValue: {}
                 .store(in: &lifetime)