This commit is contained in:
Arkadiusz Fal
2022-12-16 20:37:05 +01:00
parent b621eba236
commit f39b440b21
9 changed files with 34 additions and 18 deletions

View File

@@ -68,7 +68,7 @@ struct ChannelPlaylistView: View {
.environment(\.listingStyle, channelPlaylistListingStyle)
.onAppear {
if let playlist = presentedPlaylist,
let cache = ChannelPlaylistsCacheModel.shared.retrievePlaylist(playlist.id)
let cache = ChannelPlaylistsCacheModel.shared.retrievePlaylist(playlist)
{
store.replace(cache)
}

View File

@@ -82,8 +82,8 @@ struct FavoriteItemView: View {
ChannelsCacheModel.shared.store(channel)
}
}
case let .channelPlaylist(_, id, _):
if let cache = ChannelPlaylistsCacheModel.shared.retrievePlaylist(id),
case let .channelPlaylist(_, id, title):
if let cache = ChannelPlaylistsCacheModel.shared.retrievePlaylist(.init(id: id, title: title)),
!cache.videos.isEmpty
{
contentItems = ContentItem.array(of: cache.videos)

View File

@@ -54,7 +54,7 @@ struct PlaylistVideosView: View {
}
func loadCachedResource() {
if let cache = ChannelPlaylistsCacheModel.shared.retrievePlaylist(playlist.id) {
if let cache = ChannelPlaylistsCacheModel.shared.retrievePlaylist(playlist.channelPlaylist) {
DispatchQueue.main.async {
self.channelPlaylist.replace(cache)
}

View File

@@ -197,7 +197,8 @@ struct PlaylistsView: View {
func loadCachedResource() {
if !selectedPlaylistID.isEmpty,
let cache = ChannelPlaylistsCacheModel.shared.retrievePlaylist(selectedPlaylistID)
let currentPlaylist,
let cache = ChannelPlaylistsCacheModel.shared.retrievePlaylist(currentPlaylist.channelPlaylist)
{
DispatchQueue.main.async {
self.channelPlaylist.replace(cache)

View File

@@ -18,6 +18,7 @@ struct ContentItemView: View {
placeholderItem()
}
}
.id(item.cacheKey)
}
@ViewBuilder func videoItem(_ video: Video) -> some View {