소스 검색

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
2개의 변경된 파일2개의 추가작업 그리고 12개의 파일을 삭제
  1. 0 10
      Trio/Sources/Modules/Snooze/SnoozeStateModel.swift
  2. 2 2
      Trio/Sources/Modules/Snooze/View/SnoozeRootView.swift

+ 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