diff options
| author | Ruben Beltran del Rio <git@r.bdr.sh> | 2025-02-05 22:27:17 +0100 |
|---|---|---|
| committer | Ruben Beltran del Rio <git@r.bdr.sh> | 2025-02-05 22:27:17 +0100 |
| commit | 45829daa856b376b1ab04d415917110b71b1dec5 (patch) | |
| tree | 8e52daed6897b6f489d455736fe256cb9bd90fef /Hotline/Models/NewsInfo.swift | |
| parent | 5c3ea897d062a47bc8cd6255fb8c36bad2f0733f (diff) | |
Apply formatting
Diffstat (limited to 'Hotline/Models/NewsInfo.swift')
| -rw-r--r-- | Hotline/Models/NewsInfo.swift | 47 |
1 files changed, 23 insertions, 24 deletions
diff --git a/Hotline/Models/NewsInfo.swift b/Hotline/Models/NewsInfo.swift index 6ee28b8..caf532f 100644 --- a/Hotline/Models/NewsInfo.swift +++ b/Hotline/Models/NewsInfo.swift @@ -8,28 +8,28 @@ enum NewsInfoType { @Observable class NewsInfo: Identifiable, Hashable { let id: UUID = UUID() - + var name: String var count: UInt let type: NewsInfoType - + var categoryID: UUID? var articleID: UInt? var parentID: UInt? - + var path: [String] var expanded: Bool = false var children: [NewsInfo] = [] - + var articleFlavors: [String]? var articleUsername: String? var articleDate: Date? var read: Bool = false - + var expandable: Bool { self.type == .bundle || self.type == .category || self.children.count > 0 } - + var lookupPath: String? { switch self.type { case .bundle, .category: @@ -38,21 +38,21 @@ enum NewsInfoType { guard let aid = self.articleID else { return nil } -// if let pid = self.parentID, pid != 0 { -// return "/\(self.path.joined(separator: "/"))/\(pid)/\(aid)" -// } + // if let pid = self.parentID, pid != 0 { + // return "/\(self.path.joined(separator: "/"))/\(pid)/\(aid)" + // } return "/\(self.path.joined(separator: "/"))/\(aid)" } } - + var parentArticleLookupPath: String? { switch self.type { case .bundle, .category: -// if self.path.count <= 1 { -// return "/" -// } -// let parentPath = self.path[0..<self.path.count-1] -// return "/\(parentPath.joined(separator: "/"))" + // if self.path.count <= 1 { + // return "/" + // } + // let parentPath = self.path[0..<self.path.count-1] + // return "/\(parentPath.joined(separator: "/"))" return nil case .article: guard let pid = self.parentID, pid != 0 else { @@ -61,7 +61,7 @@ enum NewsInfoType { return "/\(self.path.joined(separator: "/"))/\(pid)" } } - + init(hotlineNewsCategory: HotlineNewsCategory) { self.categoryID = hotlineNewsCategory.id self.articleID = nil @@ -69,15 +69,14 @@ enum NewsInfoType { self.name = hotlineNewsCategory.name self.count = UInt(hotlineNewsCategory.count) self.path = hotlineNewsCategory.path - + if hotlineNewsCategory.type == 2 { self.type = .bundle - } - else { + } else { self.type = .category } } - + init(hotlineNewsArticle: HotlineNewsArticle) { self.articleID = UInt(hotlineNewsArticle.id) self.parentID = hotlineNewsArticle.parentID == 0 ? nil : UInt(hotlineNewsArticle.parentID) @@ -85,19 +84,19 @@ enum NewsInfoType { self.categoryID = nil self.name = hotlineNewsArticle.title self.count = 0 -// self.count = UInt(hotlineNewsArticle.count) + // self.count = UInt(hotlineNewsArticle.count) self.path = hotlineNewsArticle.path self.type = .article - + self.articleFlavors = hotlineNewsArticle.flavors.map { $0.0 } self.articleUsername = hotlineNewsArticle.username self.articleDate = hotlineNewsArticle.date } - + func hash(into hasher: inout Hasher) { hasher.combine(self.id) } - + static func == (lhs: NewsInfo, rhs: NewsInfo) -> Bool { return lhs.id == rhs.id } |