mirror of
https://github.com/yattee/yattee.git
synced 2024-12-22 21:43:41 +00:00
Fix channel videos cache
This commit is contained in:
parent
cb6eaa180e
commit
12005e63e1
@ -114,15 +114,6 @@ struct Channel: Identifiable, Hashable {
|
|||||||
return tabs.contains { $0.contentType == contentType }
|
return tabs.contains { $0.contentType == contentType }
|
||||||
}
|
}
|
||||||
|
|
||||||
var json: JSON {
|
|
||||||
[
|
|
||||||
"app": app.rawValue,
|
|
||||||
"id": id,
|
|
||||||
"name": name,
|
|
||||||
"thumbnailURL": thumbnailURL?.absoluteString ?? ""
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
var cacheKey: String {
|
var cacheKey: String {
|
||||||
switch app {
|
switch app {
|
||||||
case .local:
|
case .local:
|
||||||
@ -144,12 +135,23 @@ struct Channel: Identifiable, Hashable {
|
|||||||
thumbnailURL ?? ChannelsCacheModel.shared.retrieve(cacheKey)?.thumbnailURL
|
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 {
|
static func from(_ json: JSON) -> Self {
|
||||||
.init(
|
.init(
|
||||||
app: VideosApp(rawValue: json["app"].stringValue) ?? .local,
|
app: VideosApp(rawValue: json["app"].stringValue) ?? .local,
|
||||||
id: json["id"].stringValue,
|
id: json["id"].stringValue,
|
||||||
name: json["name"].stringValue,
|
name: json["name"].stringValue,
|
||||||
thumbnailURL: json["thumbnailURL"].url
|
thumbnailURL: json["thumbnailURL"].url,
|
||||||
|
videos: json["videos"].arrayValue.map { Video.from($0) }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user