Procházet zdrojové kódy

Merge pull request #335 from nightscout/beta-watch-fixes

marv-out před 1 rokem
rodič
revize
e109e72978

+ 11 - 0
Trio Watch App Extension/Views/AcknowledgementPendingView.swift

@@ -43,6 +43,17 @@ struct AcknowledgementPendingView: View {
         .navigationBarBackButtonHidden(true)
         .toolbar(.hidden)
         .background(trioBackgroundColor)
+        .onChange(of: state.showCommsAnimation) { oldValue, newValue in
+            if newValue && !oldValue {
+                DispatchQueue.main.asyncAfter(deadline: .now() + 5) {
+                    // If after 5 seconds there is still no acknowledgement banner, return to root
+                    if !state.showAcknowledgmentBanner {
+                        // Navigate back to the root
+                        navigationPath.removeLast(navigationPath.count)
+                    }
+                }
+            }
+        }
         .onChange(of: state.showAcknowledgmentBanner) { _, newValue in
             if !newValue {
                 // Navigate back to the root when acknowledgment banner disappears

+ 3 - 5
Trio Watch App Extension/WatchState.swift

@@ -110,15 +110,13 @@ import WatchConnectivity
             acknowledgmentMessage = "\(message)"
         } else {
             print("⌚️ Acknowledgment failed: \(message)")
+            DispatchQueue.main.async {
+                self.showCommsAnimation = false // Hide progress animation
+            }
             acknowledgementStatus = .failure
             acknowledgmentMessage = "\(message)"
         }
 
-        DispatchQueue.main.async {
-            self.showCommsAnimation = false // Hide progress animation
-            self.showSyncingAnimation = false // Just ensure this is 100% set to false
-        }
-
         if isFinal {
             showAcknowledgmentBanner = true
             DispatchQueue.main.asyncAfter(deadline: .now() + 2) {

+ 6 - 1
Trio/Sources/APS/OpenAPS/OpenAPS.swift

@@ -754,7 +754,12 @@ final class OpenAPS {
         }
 
         if let url = Foundation.Bundle.main.url(forResource: "javascript/\(name)", withExtension: "") {
-            return Script(name: name, body: try! String(contentsOf: url))
+            do {
+                let body = try String(contentsOf: url)
+                return Script(name: name, body: body)
+            } catch {
+                debug(.openAPS, "Failed to load script \(name): \(error)")
+            }
         }
 
         return nil