Channels caching

This commit is contained in:
Arkadiusz Fal
2022-12-14 00:07:32 +01:00
parent d9622cf24c
commit 3b31f21c81
18 changed files with 151 additions and 18 deletions

View File

@@ -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()