Build 21
This commit is contained in:
@@ -10,14 +10,10 @@ final class LiveActivityManager {
|
||||
static let shared = LiveActivityManager()
|
||||
private init() {}
|
||||
|
||||
private var currentActivity: Activity<SessionActivityAttributes>?
|
||||
nonisolated(unsafe) private var currentActivity: Activity<SessionActivityAttributes>?
|
||||
private var healthCheckTimer: Timer?
|
||||
private var lastHealthCheck: Date = Date()
|
||||
|
||||
deinit {
|
||||
healthCheckTimer?.invalidate()
|
||||
}
|
||||
|
||||
/// Check if there's an active session and restart Live Activity if needed
|
||||
func restartLiveActivityIfNeeded(activeSession: ClimbSession?, gymName: String?) async {
|
||||
// If we have an active session but no Live Activity, restart it
|
||||
@@ -130,7 +126,8 @@ final class LiveActivityManager {
|
||||
completedProblems: completedProblems
|
||||
)
|
||||
|
||||
await currentActivity.update(.init(state: updatedContentState, staleDate: nil))
|
||||
nonisolated(unsafe) let activity = currentActivity
|
||||
await activity.update(.init(state: updatedContentState, staleDate: nil))
|
||||
}
|
||||
|
||||
/// Call this when a ClimbSession ends to end the Live Activity
|
||||
@@ -141,7 +138,8 @@ final class LiveActivityManager {
|
||||
// First end the tracked activity if it exists
|
||||
if let currentActivity {
|
||||
print("Ending tracked Live Activity: \(currentActivity.id)")
|
||||
await currentActivity.end(nil, dismissalPolicy: .immediate)
|
||||
nonisolated(unsafe) let activity = currentActivity
|
||||
await activity.end(nil, dismissalPolicy: .immediate)
|
||||
self.currentActivity = nil
|
||||
print("Tracked Live Activity ended successfully")
|
||||
}
|
||||
@@ -200,7 +198,7 @@ final class LiveActivityManager {
|
||||
print("🩺 Starting Live Activity health checks")
|
||||
healthCheckTimer = Timer.scheduledTimer(withTimeInterval: 30.0, repeats: true) {
|
||||
[weak self] _ in
|
||||
Task { @MainActor in
|
||||
Task { @MainActor [weak self] in
|
||||
await self?.performHealthCheck()
|
||||
}
|
||||
}
|
||||
@@ -257,7 +255,7 @@ final class LiveActivityManager {
|
||||
{
|
||||
guard currentActivity != nil else { return }
|
||||
|
||||
Task {
|
||||
Task { @MainActor in
|
||||
while currentActivity != nil {
|
||||
let elapsed = Date().timeIntervalSince(session.startTime ?? session.date)
|
||||
await updateLiveActivity(
|
||||
|
||||
Reference in New Issue
Block a user