mirror of
https://github.com/yattee/yattee.git
synced 2025-08-04 01:34:10 +00:00
Channels caching
This commit is contained in:
@@ -133,7 +133,18 @@ struct ChannelVideosView: View {
|
||||
}
|
||||
#endif
|
||||
.onAppear {
|
||||
resource?.loadIfNeeded()
|
||||
if let channel,
|
||||
let cache = ChannelsCacheModel.shared.retrieve(channel.cacheKey),
|
||||
store.item.isNil
|
||||
{
|
||||
store.replace(cache)
|
||||
}
|
||||
|
||||
resource?.loadIfNeeded()?.onSuccess { response in
|
||||
if let channel: Channel = response.typedContent() {
|
||||
ChannelsCacheModel.shared.store(channel)
|
||||
}
|
||||
}
|
||||
}
|
||||
.onChange(of: contentType) { _ in
|
||||
resource?.load()
|
||||
|
@@ -121,7 +121,7 @@ struct FavoriteItemView: View {
|
||||
Group {
|
||||
switch item.section {
|
||||
case let .channel(_, id, name):
|
||||
ChannelVideosView(channel: .init(id: id, name: name))
|
||||
ChannelVideosView(channel: .init(app: .invidious, id: id, name: name))
|
||||
case let .channelPlaylist(_, id, title):
|
||||
ChannelPlaylistView(playlist: .init(id: id, title: title))
|
||||
case let .playlist(_, id):
|
||||
@@ -140,7 +140,7 @@ struct FavoriteItemView: View {
|
||||
func itemButtonAction() {
|
||||
switch item.section {
|
||||
case let .channel(_, id, name):
|
||||
NavigationModel.shared.openChannel(.init(id: id, name: name), navigationStyle: navigationStyle)
|
||||
NavigationModel.shared.openChannel(.init(app: .invidious, id: id, name: name), navigationStyle: navigationStyle)
|
||||
case let .channelPlaylist(_, id, title):
|
||||
NavigationModel.shared.openChannelPlaylist(.init(id: id, title: title), navigationStyle: navigationStyle)
|
||||
case .subscriptions:
|
||||
|
@@ -15,7 +15,7 @@ struct ChannelsView: View {
|
||||
ForEach(subscriptions.all) { channel in
|
||||
NavigationLink(destination: ChannelVideosView(channel: channel).modifier(PlayerOverlayModifier())) {
|
||||
HStack {
|
||||
if let url = channel.thumbnailURL {
|
||||
if let url = channel.thumbnailURLOrCached {
|
||||
ThumbnailView(url: url)
|
||||
.frame(width: 35, height: 35)
|
||||
.clipShape(RoundedRectangle(cornerRadius: 35))
|
||||
|
@@ -74,8 +74,11 @@ struct VideoBanner: View {
|
||||
|
||||
HStack {
|
||||
HStack {
|
||||
if !inChannelView {
|
||||
ThumbnailView(url: video?.channel.thumbnailURL)
|
||||
if !inChannelView,
|
||||
let video,
|
||||
let url = video.channel.thumbnailURLOrCached
|
||||
{
|
||||
ThumbnailView(url: url)
|
||||
.frame(width: 30, height: 30)
|
||||
.clipShape(Circle())
|
||||
}
|
||||
|
@@ -166,8 +166,18 @@ struct VideoCell: View {
|
||||
videoDetail(video.displayTitle, lineLimit: 5)
|
||||
.frame(minWidth: 0, maxWidth: .infinity, alignment: .leading)
|
||||
|
||||
if !channelOnThumbnail, !inChannelView {
|
||||
channelControl(badge: false)
|
||||
HStack(spacing: 12) {
|
||||
if !inChannelView,
|
||||
let video,
|
||||
let url = video.channel.thumbnailURLOrCached
|
||||
{
|
||||
ThumbnailView(url: url)
|
||||
.frame(width: 30, height: 30)
|
||||
.clipShape(Circle())
|
||||
}
|
||||
if !channelOnThumbnail, !inChannelView {
|
||||
channelControl(badge: false)
|
||||
}
|
||||
}
|
||||
|
||||
if additionalDetailsAvailable {
|
||||
@@ -271,6 +281,15 @@ struct VideoCell: View {
|
||||
.padding(.bottom, 4)
|
||||
|
||||
HStack(spacing: 8) {
|
||||
if !inChannelView,
|
||||
let video,
|
||||
let url = video.channel.thumbnailURLOrCached
|
||||
{
|
||||
ThumbnailView(url: url)
|
||||
.frame(width: 30, height: 30)
|
||||
.clipShape(Circle())
|
||||
}
|
||||
|
||||
if let date = video.publishedDate {
|
||||
HStack(spacing: 2) {
|
||||
Text(date)
|
||||
@@ -512,7 +531,7 @@ struct VideoCell_Preview: PreviewProvider {
|
||||
#if os(macOS)
|
||||
.frame(maxWidth: 300, maxHeight: 250)
|
||||
#elseif os(iOS)
|
||||
.frame(maxWidth: 300, maxHeight: 200)
|
||||
.frame(maxWidth: 600, maxHeight: 200)
|
||||
#endif
|
||||
.injectFixtureEnvironmentObjects()
|
||||
}
|
||||
|
Reference in New Issue
Block a user