updates for lock screen, foxed graphs on front end

This commit is contained in:
Mark Gregory
2026-11-04 15:29:03 +00:00
parent b16c56baab
commit 280a459377
4 changed files with 17 additions and 3 deletions
+1 -1
View File
@@ -287,7 +287,7 @@ struct TransferHistoryChart: View {
private var end: Date { updatedAt ?? Date() }
private var start: Date { end.addingTimeInterval(-Double(minutes * 60)) }
private var samples: [TransferSample] { history.samples.filter { $0.date >= start && $0.date <= end } }
private var samples: [TransferSample] { history.samples(from: start, through: end) }
private var selectedSample: TransferSample? {
guard let selection else { return nil }
return samples.min { abs($0.date.timeIntervalSince(selection)) < abs($1.date.timeIntervalSince(selection)) }
+11 -1
View File
@@ -140,9 +140,19 @@ struct TransferHistory {
private(set) var samples: [TransferSample] = []
private var segment = 0
func samples(from start: Date, through end: Date) -> [TransferSample] {
let lower = start.timeIntervalSinceReferenceDate
let upper = end.timeIntervalSinceReferenceDate
// Avoid SDK-new Date >= / <= entry points missing from some iOS betas.
return samples.filter {
let time = $0.date.timeIntervalSinceReferenceDate
return time >= lower && time <= upper
}
}
mutating func record(download: Int64, upload: Int64, at date: Date = Date()) {
if let last = samples.last {
guard date >= last.date else { return }
guard date.timeIntervalSinceReferenceDate >= last.date.timeIntervalSinceReferenceDate else { return }
if date.timeIntervalSince(last.date) > 10 { segment += 1 }
// Extra action/manual refreshes must not inflate the history buffer.
if date.timeIntervalSince(last.date) < 1 { samples.removeLast() }
+1 -1
View File
@@ -15,7 +15,7 @@
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>5</string>
<string>6</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSFaceIDUsageDescription</key>
+4
View File
@@ -249,6 +249,10 @@ final class MockProtocol: URLProtocol, @unchecked Sendable {
check(liveHistory.transferHistory.samples.count == 1, "Failed refresh never fabricates a speed sample")
liveHistory.disconnect()
check(liveHistory.transferHistory.samples.isEmpty, "Disconnect removes actual collected history")
var windowHistory = TransferHistory()
for second in [0, 3, 6] { windowHistory.record(download: 1, upload: 2, at: origin.addingTimeInterval(Double(second))) }
check(windowHistory.samples(from: origin.addingTimeInterval(3), through: origin.addingTimeInterval(6)).count == 2, "History window includes exact timestamp boundaries without new Date comparison entry points")
check(windowHistory.samples(from: origin.addingTimeInterval(7), through: origin.addingTimeInterval(9)).isEmpty, "History window excludes samples outside its numeric time range")
another.close(); transport.close(); print("\(checks) contract checks passed.")
}
}