Преглед изворни кода

Refactor Snooze functionality by removing the handleSnoozeResponse method and updating the formatInterval method to handle nil values gracefully. Adjusted snooze description logic to utilize the new formatInterval method.

Trio Build Bot пре 1 месец
родитељ
комит
ebab072e5b

+ 0 - 10
Trio/Sources/Modules/Snooze/SnoozeStateModel.swift

@@ -27,16 +27,6 @@ extension Snooze {
                 .contains(duration)
         }
 
-        // Add handleSnoozeResponse inside the class
-        func handleSnoozeResponse(_ duration: TimeInterval) {
-            guard validateSnoozeDuration(duration) else { return }
-
-            Task { @MainActor in
-                snoozeUntilDate = Date().addingTimeInterval(duration)
-                alarm = glucoseStorage.alarm
-            }
-        }
-
         @MainActor func applySnooze(_ duration: TimeInterval) async {
             // Allow any duration chosen in the Snooze UI, while keeping validation for quick actions elsewhere.
             snoozeUntilDate = duration > 0 ? Date().addingTimeInterval(duration) : .distantPast

+ 2 - 2
Trio/Sources/Modules/Snooze/View/SnoozeRootView.swift

@@ -36,7 +36,7 @@ extension Snooze {
         }
 
         private func formatInterval(_ interval: TimeInterval) -> String {
-            formatter.string(from: interval)!
+            formatter.string(from: interval) ?? ""
         }
 
         func getSnoozeDescription() -> String {
@@ -68,7 +68,7 @@ extension Snooze {
             VStack(alignment: .leading) {
                 Button {
                     let interval = pickerTimes[selectedInterval]
-                    let snoozeFor = formatter.string(from: interval)!
+                    let snoozeFor = formatInterval(interval)
                     let untilDate = Date() + interval
 
                     Task { @MainActor [weak state] in