1
0
mirror of https://github.com/yattee/yattee.git synced 2024-12-13 05:40:32 +05:30
yattee/Model/Channel.swift

47 lines
1.1 KiB
Swift
Raw Normal View History

2021-06-28 20:32:13 +05:30
import AVFoundation
import Defaults
import Foundation
2021-08-26 03:42:59 +05:30
import SwiftyJSON
2021-06-28 20:32:13 +05:30
struct Channel: Identifiable, Hashable {
2021-06-28 20:32:13 +05:30
var id: String
var name: String
var thumbnailURL: URL?
var videos = [Video]()
private var subscriptionsCount: Int?
private var subscriptionsText: String?
2021-06-28 20:32:13 +05:30
init(
id: String,
name: String,
thumbnailURL: URL? = nil,
subscriptionsCount: Int? = nil,
subscriptionsText: String? = nil,
videos: [Video] = []
) {
2021-08-26 03:42:59 +05:30
self.id = id
self.name = name
self.thumbnailURL = thumbnailURL
2021-08-26 03:42:59 +05:30
self.subscriptionsCount = subscriptionsCount
self.subscriptionsText = subscriptionsText
self.videos = videos
}
2021-12-18 01:31:05 +05:30
var detailsLoaded: Bool {
!subscriptionsString.isNil
}
var subscriptionsString: String? {
if subscriptionsCount != nil, subscriptionsCount! > 0 {
return subscriptionsCount!.formattedAsAbbreviation()
}
return subscriptionsText
}
func hash(into hasher: inout Hasher) {
hasher.combine(id)
2021-06-28 20:32:13 +05:30
}
}