1
0
mirror of https://github.com/yattee/yattee.git synced 2024-12-13 22:00:31 +05:30

Fix channel videos cache

This commit is contained in:
Arkadiusz Fal 2022-12-15 12:09:41 +01:00
parent cb6eaa180e
commit 12005e63e1

View File

@ -114,15 +114,6 @@ struct Channel: Identifiable, Hashable {
return tabs.contains { $0.contentType == contentType }
}
var json: JSON {
[
"app": app.rawValue,
"id": id,
"name": name,
"thumbnailURL": thumbnailURL?.absoluteString ?? ""
]
}
var cacheKey: String {
switch app {
case .local:
@ -144,12 +135,23 @@ struct Channel: Identifiable, Hashable {
thumbnailURL ?? ChannelsCacheModel.shared.retrieve(cacheKey)?.thumbnailURL
}
var json: JSON {
[
"app": app.rawValue,
"id": id,
"name": name,
"thumbnailURL": thumbnailURL?.absoluteString ?? "",
"videos": videos.map { $0.json.object }
]
}
static func from(_ json: JSON) -> Self {
.init(
app: VideosApp(rawValue: json["app"].stringValue) ?? .local,
id: json["id"].stringValue,
name: json["name"].stringValue,
thumbnailURL: json["thumbnailURL"].url
thumbnailURL: json["thumbnailURL"].url,
videos: json["videos"].arrayValue.map { Video.from($0) }
)
}
}