Refactor data sources and feed model

This commit is contained in:
2026-01-10 00:25:36 +00:00
parent 1e65a3f57d
commit 324b35a464
15 changed files with 631 additions and 609 deletions

View File

@@ -75,7 +75,7 @@ struct CandidatesView: View {
}
private struct CandidateRow: View {
let candidate: Candidate
let candidate: FeedItem
var body: some View {
VStack(alignment: .leading, spacing: 6) {
@@ -88,29 +88,22 @@ private struct CandidateRow: View {
.font(.caption)
.foregroundStyle(.secondary)
}
Text(candidate.subtitle)
.font(.subheadline)
.foregroundStyle(.secondary)
.lineLimit(1)
if !candidate.subtitle.isEmpty {
Text(candidate.subtitle)
.font(.subheadline)
.foregroundStyle(.secondary)
.lineLimit(1)
}
HStack(spacing: 12) {
Text(String(format: "conf %.2f", candidate.confidence))
Text(String(format: "prio %.2f", candidate.priority))
Text("ttl \(candidate.ttlSec)s")
Text(expiresText(now: Int(Date().timeIntervalSince1970)))
}
.font(.caption)
.foregroundStyle(.secondary)
}
.padding(.vertical, 4)
}
private func expiresText(now: Int) -> String {
let expiresAt = candidate.createdAt + candidate.ttlSec
let remaining = expiresAt - now
if remaining <= 0 { return "expired" }
if remaining < 60 { return "in \(remaining)s" }
return "in \(remaining / 60)m"
}
}
struct CandidatesView_Previews: PreviewProvider {