1.2.2 - "Bug fixes and improvements"
This commit is contained in:
@@ -34,11 +34,11 @@ final class LiveActivityManager {
|
||||
let isStillActive = activities.contains { $0.id == currentActivity.id }
|
||||
|
||||
if isStillActive {
|
||||
print("ℹ️ Live Activity still running: \(currentActivity.id)")
|
||||
print("Live Activity still running: \(currentActivity.id)")
|
||||
return
|
||||
} else {
|
||||
print(
|
||||
"⚠️ Tracked Live Activity \(currentActivity.id) was dismissed, clearing reference"
|
||||
"WARNING: Tracked Live Activity \(currentActivity.id) was dismissed, clearing reference"
|
||||
)
|
||||
self.currentActivity = nil
|
||||
}
|
||||
@@ -47,18 +47,18 @@ final class LiveActivityManager {
|
||||
// Check if there are ANY active Live Activities for this session
|
||||
let existingActivities = Activity<SessionActivityAttributes>.activities
|
||||
if let existingActivity = existingActivities.first {
|
||||
print("ℹ️ Found existing Live Activity: \(existingActivity.id), using it")
|
||||
print("Found existing Live Activity: \(existingActivity.id), using it")
|
||||
self.currentActivity = existingActivity
|
||||
return
|
||||
}
|
||||
|
||||
print("🔄 No Live Activity found, restarting for existing session")
|
||||
print("No Live Activity found, restarting for existing session")
|
||||
await startLiveActivity(for: activeSession, gymName: gymName)
|
||||
}
|
||||
|
||||
/// Call this when a ClimbSession starts to begin a Live Activity
|
||||
func startLiveActivity(for session: ClimbSession, gymName: String) async {
|
||||
print("🔴 Starting Live Activity for gym: \(gymName)")
|
||||
print("Starting Live Activity for gym: \(gymName)")
|
||||
|
||||
await endLiveActivity()
|
||||
|
||||
@@ -84,9 +84,9 @@ final class LiveActivityManager {
|
||||
pushType: nil
|
||||
)
|
||||
self.currentActivity = activity
|
||||
print("✅ Live Activity started successfully: \(activity.id)")
|
||||
print("Live Activity started successfully: \(activity.id)")
|
||||
} catch {
|
||||
print("❌ Failed to start live activity: \(error)")
|
||||
print("ERROR: Failed to start live activity: \(error)")
|
||||
print("Error details: \(error.localizedDescription)")
|
||||
|
||||
// Check specific error types
|
||||
@@ -104,7 +104,7 @@ final class LiveActivityManager {
|
||||
func updateLiveActivity(elapsed: TimeInterval, totalAttempts: Int, completedProblems: Int) async
|
||||
{
|
||||
guard let currentActivity = currentActivity else {
|
||||
print("⚠️ No current activity to update")
|
||||
print("WARNING: No current activity to update")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -114,14 +114,14 @@ final class LiveActivityManager {
|
||||
|
||||
if !isStillActive {
|
||||
print(
|
||||
"⚠️ Tracked Live Activity \(currentActivity.id) is no longer active, clearing reference"
|
||||
"WARNING: Tracked Live Activity \(currentActivity.id) is no longer active, clearing reference"
|
||||
)
|
||||
self.currentActivity = nil
|
||||
return
|
||||
}
|
||||
|
||||
print(
|
||||
"🔄 Updating Live Activity - Attempts: \(totalAttempts), Completed: \(completedProblems)"
|
||||
"Updating Live Activity - Attempts: \(totalAttempts), Completed: \(completedProblems)"
|
||||
)
|
||||
|
||||
let updatedContentState = SessionActivityAttributes.ContentState(
|
||||
@@ -131,7 +131,7 @@ final class LiveActivityManager {
|
||||
)
|
||||
|
||||
await currentActivity.update(.init(state: updatedContentState, staleDate: nil))
|
||||
print("✅ Live Activity updated successfully")
|
||||
print("Live Activity updated successfully")
|
||||
}
|
||||
|
||||
/// Call this when a ClimbSession ends to end the Live Activity
|
||||
@@ -141,25 +141,25 @@ final class LiveActivityManager {
|
||||
|
||||
// First end the tracked activity if it exists
|
||||
if let currentActivity {
|
||||
print("🔴 Ending tracked Live Activity: \(currentActivity.id)")
|
||||
print("Ending tracked Live Activity: \(currentActivity.id)")
|
||||
await currentActivity.end(nil, dismissalPolicy: .immediate)
|
||||
self.currentActivity = nil
|
||||
print("✅ Tracked Live Activity ended successfully")
|
||||
print("Tracked Live Activity ended successfully")
|
||||
}
|
||||
|
||||
// Force end ALL active activities of our type to ensure cleanup
|
||||
print("🔍 Checking for any remaining active activities...")
|
||||
print("Checking for any remaining active activities...")
|
||||
let activities = Activity<SessionActivityAttributes>.activities
|
||||
|
||||
if activities.isEmpty {
|
||||
print("ℹ️ No additional activities found")
|
||||
print("No additional activities found")
|
||||
} else {
|
||||
print("🔴 Found \(activities.count) additional active activities, ending them...")
|
||||
print("Found \(activities.count) additional active activities, ending them...")
|
||||
for activity in activities {
|
||||
print("🔴 Force ending activity: \(activity.id)")
|
||||
print("Force ending activity: \(activity.id)")
|
||||
await activity.end(nil, dismissalPolicy: .immediate)
|
||||
}
|
||||
print("✅ All Live Activities ended successfully")
|
||||
print("All Live Activities ended successfully")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,7 +188,7 @@ final class LiveActivityManager {
|
||||
if let currentActivity = currentActivity {
|
||||
let isStillActive = activities.contains { $0.id == currentActivity.id }
|
||||
if !isStillActive {
|
||||
print("🧹 Cleaning up dismissed Live Activity: \(currentActivity.id)")
|
||||
print("Cleaning up dismissed Live Activity: \(currentActivity.id)")
|
||||
self.currentActivity = nil
|
||||
}
|
||||
}
|
||||
@@ -211,7 +211,7 @@ final class LiveActivityManager {
|
||||
func stopHealthChecks() {
|
||||
healthCheckTimer?.invalidate()
|
||||
healthCheckTimer = nil
|
||||
print("🛑 Stopped Live Activity health checks")
|
||||
print("Stopped Live Activity health checks")
|
||||
}
|
||||
|
||||
/// Perform a health check on the current Live Activity
|
||||
@@ -231,7 +231,7 @@ final class LiveActivityManager {
|
||||
let isStillActive = activities.contains { $0.id == currentActivity.id }
|
||||
|
||||
if !isStillActive {
|
||||
print("💔 Health check failed - Live Activity was dismissed")
|
||||
print("Health check failed - Live Activity was dismissed")
|
||||
self.currentActivity = nil
|
||||
|
||||
// Notify that we need to restart
|
||||
@@ -240,7 +240,7 @@ final class LiveActivityManager {
|
||||
object: nil
|
||||
)
|
||||
} else {
|
||||
print("✅ Live Activity health check passed")
|
||||
print("Live Activity health check passed")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user