Przeglądaj źródła

Merge pull request #499 from nightscout/live-activity-pushdata

marv-out 1 rok temu
rodzic
commit
1ff357098d

+ 7 - 2
Trio/Sources/Services/LiveActivity/LiveActivityManager.swift

@@ -305,7 +305,10 @@ final class LiveActivityManager: Injectable, ObservableObject, SettingsObserver
         if let currentActivity = currentActivity {
         if let currentActivity = currentActivity {
             if currentActivity.needsRecreation(), UIApplication.shared.applicationState == .active {
             if currentActivity.needsRecreation(), UIApplication.shared.applicationState == .active {
                 await endActivity()
                 await endActivity()
-                await pushUpdate(state)
+                Task { @MainActor in
+                    await self.pushUpdate(state)
+                }
+                return
             } else {
             } else {
                 let content = ActivityContent(
                 let content = ActivityContent(
                     state: state,
                     state: state,
@@ -408,7 +411,9 @@ final class LiveActivityManager: Injectable, ObservableObject, SettingsObserver
             try? await Task.sleep(nanoseconds: 200_000_000) // 0.2s sleep
             try? await Task.sleep(nanoseconds: 200_000_000) // 0.2s sleep
         }
         }
 
 
-        await pushUpdate(contentState)
+        Task { @MainActor in
+            await self.pushUpdate(contentState)
+        }
         debug(.default, "Restarted Live Activity from LiveActivityIntent (via iOS Shortcut)")
         debug(.default, "Restarted Live Activity from LiveActivityIntent (via iOS Shortcut)")
     }
     }
 }
 }