Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions LoopFollow/Helpers/BackgroundTaskAudio.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,10 @@ class BackgroundTask {
LogManager.shared.log(category: .general, message: "[LA] Silent audio session interrupted (began)")

case .ended:
// Check shouldResume hint — skip restart if iOS says not to
if let optionsValue = userInfo[AVAudioSessionInterruptionOptionKey] as? UInt {
let options = AVAudioSession.InterruptionOptions(rawValue: optionsValue)
guard options.contains(.shouldResume) else {
LogManager.shared.log(category: .general, message: "[LA] Silent audio interruption ended — shouldResume not set, skipping restart")
return
if !options.contains(.shouldResume) {
LogManager.shared.log(category: .general, message: "[LA] Silent audio interruption ended — shouldResume not set, attempting restart anyway")
}
}
LogManager.shared.log(category: .general, message: "[LA] Silent audio interruption ended — scheduling restart in 0.5s")
Expand All @@ -54,6 +52,7 @@ class BackgroundTask {
self?.playAudio()
}


@unknown default:
break
}
Expand Down
10 changes: 10 additions & 0 deletions LoopFollow/LiveActivity/GlucoseLiveActivityAttributes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ struct GlucoseLiveActivityAttributes: ActivityAttributes {
let producedAtInterval = try container.decode(Double.self, forKey: .producedAt)
producedAt = Date(timeIntervalSince1970: producedAtInterval)
}

func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(snapshot, forKey: .snapshot)
try container.encode(seq, forKey: .seq)
try container.encode(reason, forKey: .reason)
try container.encode(producedAt.timeIntervalSince1970, forKey: .producedAt)
}



private enum CodingKeys: String, CodingKey {
case snapshot, seq, reason, producedAt
Expand Down