From 87e979fb48da4a46e64544cea3e7b7d5fc32caa1 Mon Sep 17 00:00:00 2001 From: Dustin Mierau Date: Tue, 14 May 2024 13:35:26 -0700 Subject: Newsgroup posting now works. Added reload button to news. More work on server and user icons. --- Hotline/Models/NewsInfo.swift | 44 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 38 insertions(+), 6 deletions(-) (limited to 'Hotline/Models/NewsInfo.swift') diff --git a/Hotline/Models/NewsInfo.swift b/Hotline/Models/NewsInfo.swift index eecd550..6ee28b8 100644 --- a/Hotline/Models/NewsInfo.swift +++ b/Hotline/Models/NewsInfo.swift @@ -9,15 +9,15 @@ enum NewsInfoType { @Observable class NewsInfo: Identifiable, Hashable { let id: UUID = UUID() - let name: String - let count: UInt + var name: String + var count: UInt let type: NewsInfoType - let categoryID: UUID? - let articleID: UInt? - let parentID: UInt? + var categoryID: UUID? + var articleID: UInt? + var parentID: UInt? - let path: [String] + var path: [String] var expanded: Bool = false var children: [NewsInfo] = [] @@ -30,6 +30,38 @@ enum NewsInfoType { self.type == .bundle || self.type == .category || self.children.count > 0 } + var lookupPath: String? { + switch self.type { + case .bundle, .category: + return "/\(self.path.joined(separator: "/"))" + case .article: + guard let aid = self.articleID else { + return nil + } +// 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..