Persist author cache to disk for instant channel info across restarts

Back the in-memory authorCache with a JSON file in ~/Library/Caches/AuthorCache/.
Disk is lazy-loaded on first lookup and saved asynchronously on each cache update.
Capped at 500 entries to prevent unbounded growth.

- Cache author data from video detail API responses (PlayerService, VideoInfoView)
- Replace ChannelView's private CachedChannelHeader with shared CachedChannelData
- Enrich author with cached avatar/subscriber count in VideoChannelRow, TVDetailsPanel, VideoInfoView
This commit is contained in:
Arkadiusz Fal
2026-02-12 05:47:43 +01:00
parent d1d7edb5ec
commit fd41833532
6 changed files with 185 additions and 37 deletions

View File

@@ -152,10 +152,17 @@ struct TVDetailsPanel: View {
// MARK: - Channel Row
/// Author enriched with cached channel data (avatar, subscriber count) from local stores.
private var enrichedAuthor: Author? {
guard let video else { return nil }
guard let dataManager = appEnvironment?.dataManager else { return video.author }
return video.author.enriched(using: dataManager)
}
private var channelRow: some View {
HStack(spacing: 16) {
// Channel avatar
if let thumbnailURL = video?.author.thumbnailURL {
if let thumbnailURL = enrichedAuthor?.thumbnailURL {
AsyncImage(url: thumbnailURL) { image in
image
.resizable()
@@ -179,12 +186,12 @@ struct TVDetailsPanel: View {
VStack(alignment: .leading, spacing: 4) {
// Channel name
Text(video?.author.name ?? "")
Text(enrichedAuthor?.name ?? "")
.font(.headline)
.foregroundStyle(.white)
// Subscriber count
if let subscriberCount = video?.author.subscriberCount {
if let subscriberCount = enrichedAuthor?.subscriberCount {
Text("channel.subscriberCount \(CountFormatter.compact(subscriberCount))")
.font(.subheadline)
.foregroundStyle(.white.opacity(0.6))