Skip to content

Commit

Permalink
Better handling of orphaned activities.
Browse files Browse the repository at this point in the history
  • Loading branch information
msimms committed Aug 28, 2023
1 parent 66eb31e commit f9ea8e1
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions View Models/LiveActivityVM.swift
Original file line number Diff line number Diff line change
Expand Up @@ -97,21 +97,27 @@ class LiveActivityVM : ObservableObject {

let orphanedActivityIdPtr = UnsafeRawPointer(ConvertActivityIndexToActivityId(orphanedActivityIndex)) // const char*, no need to dealloc
let orphanedActivityTypePtr = UnsafeRawPointer(GetHistoricalActivityType(orphanedActivityIndex))
var activityRecreated = false

defer {
orphanedActivityTypePtr!.deallocate()
}

activityTypeToUse = String(cString: orphanedActivityTypePtr!.assumingMemoryBound(to: CChar.self))
let orphanedActivityType = String(cString: orphanedActivityTypePtr!.assumingMemoryBound(to: CChar.self))
if orphanedActivityType.count > 0 {
activityTypeToUse = orphanedActivityType

if recreateOrphanedActivities {
ReCreateOrphanedActivity(orphanedActivityIndex)

self.activityId = String(cString: orphanedActivityIdPtr!.assumingMemoryBound(to: CChar.self))
self.isInProgress = true
isNewActivity = false
if recreateOrphanedActivities {
ReCreateOrphanedActivity(orphanedActivityIndex)

self.activityId = String(cString: orphanedActivityIdPtr!.assumingMemoryBound(to: CChar.self))
self.isInProgress = true
isNewActivity = false
activityRecreated = true
}
}
else {

if activityRecreated == false {
self.loadHistoricalActivityByIndex(activityIndex: orphanedActivityIndex)
}
}
Expand Down

0 comments on commit f9ea8e1

Please sign in to comment.