Pārlūkot izejas kodu

Merge branch 'dev' of github.com:nightscout/Trio into snoozeNoPodAlert

Marvin Polscheit 11 mēneši atpakaļ
vecāks
revīzija
931715f80d

+ 1 - 1
Config.xcconfig

@@ -19,7 +19,7 @@ TRIO_APP_GROUP_ID = group.org.nightscout.$(DEVELOPMENT_TEAM).trio.trio-app-group
 
 // The developers set the version numbers, please leave them alone
 APP_VERSION = 0.5.0
-APP_DEV_VERSION = 0.5.0.28
+APP_DEV_VERSION = 0.5.0.29
 APP_BUILD_NUMBER = 1
 COPYRIGHT_NOTICE =
 

+ 14 - 1
Trio/Sources/Services/LiveActivity/LiveActivityManager.swift

@@ -360,12 +360,21 @@ final class LiveActivityManager: Injectable, ObservableObject, SettingsObserver
                 )
                 currentActivity = ActiveActivity(activity: activity, startDate: Date.now)
                 debug(.default, "[LiveActivityManager] Created new activity: \(activity.id)")
-                await pushUpdate(state)
+
+                // Update the newly created activity with actual data
+                let updateContent = ActivityContent(
+                    state: state,
+                    staleDate: Date.now.addingTimeInterval(5 * 60)
+                )
+                await activity.update(updateContent)
+                debug(.default, "[LiveActivityManager] Updated new activity with actual data")
             } catch {
                 debug(
                     .default,
                     "\(#file): Error creating new activity: \(error)"
                 )
+                // Reset currentActivity on error to allow retry on next update
+                currentActivity = nil
             }
         }
     }
@@ -428,6 +437,10 @@ final class LiveActivityManager: Injectable, ObservableObject, SettingsObserver
             try? await Task.sleep(nanoseconds: 200_000_000) // 0.2s sleep
         }
 
+        // Add additional delay to ensure iOS has fully cleaned up the previous activity
+        debug(.default, "Waiting additional time for iOS to clean up...")
+        try? await Task.sleep(nanoseconds: 1_000_000_000) // 1s additional delay
+
         Task { @MainActor in
             await self.pushUpdate(contentState)
         }