Selaa lähdekoodia

Reclassify Info messages related to pump as MessageSubtype.pump

kskandis 1 vuosi sitten
vanhempi
commit
742b7f2460

+ 5 - 0
Trio/Sources/APS/APSManager.swift

@@ -52,6 +52,11 @@ enum APSError: LocalizedError {
             return "Manual Basal Temp : \(message)"
         }
     }
+
+    static func pumpMatches(message: String) -> Bool {
+        message.contains("Pump error:") || message.contains("Invalid Pump State:") || message.contains("PumpMessage") || message
+            .contains("PumpOpsError") || message.contains("RileyLink")
+    }
 }
 
 final class BaseAPSManager: APSManager, Injectable {

+ 6 - 4
Trio/Sources/Modules/Main/MainStateModel.swift

@@ -204,8 +204,10 @@ extension Main {
         /*
           Reclassification is needed for Medtronic pumps for 'Pump error:' RileyLink related messages.
           For details, see https://discord.com/channels/1020905149037813862/1338245444186279946/1343469793013141525.
-          Reclassification of Info type messages is based on APSManager.APSError enum values.
-          Currently, we only re-classify APSError.pumpError 'Pump error:' type to MessageType.error.
+          These messages are repeatedly displayed causing users to simply ignore them.
+          Reclassification of these Info type messages is based on APSManager.APSError enum values.
+          We reclassify APSError.pumpError and APSError.invalidPumpState as MessageType.info and MessageSubtype.pump.
+          This allows the user to disable these messages using using the 'Trio Notification' -> 'Always Notify Pump' setting.
           MessageType.error messagges are always displayed to the user and the user cannot disable them.
           Other APSManager.APSError remain as MessageType.info which allows users to disable them
           using the 'Trio Notification' -> 'Always Notify Algorithm' setting.
@@ -216,8 +218,8 @@ extension Main {
                 case .info:
                     if let errorIndex = message.content.range(of: "error", options: .caseInsensitive) {
                         message.title = String(localized: "Error", comment: "Error title")
-                        if let errorPumpIndex = message.content.range(of: "Pump error:", options: .caseInsensitive) {
-                            message.type = .error
+                        if APSError.pumpMatches(message: message.content) {
+                            message.subtype = .pump
                         }
                     } else {
                         message.title = String(localized: "Info", comment: "Info title")

+ 5 - 1
Trio/Sources/Services/UserNotifications/UserNotificationsManager.swift

@@ -492,7 +492,11 @@ extension BaseUserNotificationsManager: alertMessageNotificationObserver {
         }
         switch message.subtype {
         case .pump:
-            identifier = .pumpNotification
+            if message.type == .info {
+                identifier = Identifier.alertMessageNotification
+            } else {
+                identifier = .pumpNotification
+            }
         case .carb:
             identifier = .carbsRequiredNotification
         case .glucose: