mirror of
https://github.com/yattee/yattee.git
synced 2026-02-20 01:39:46 +00:00
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:
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user