// // StatusItem.swift // Mastodon // // Created by MainasuK on 2022-1-11. // import Foundation import CoreDataStack import MastodonUI enum StatusItem: Hashable { case feed(record: ManagedObjectRecord) case feedLoader(record: ManagedObjectRecord) case status(record: ManagedObjectRecord) case thread(Thread) case topLoader case bottomLoader } extension StatusItem { enum Thread: Hashable { case root(context: Context) case reply(context: Context) case leaf(context: Context) public var record: ManagedObjectRecord { switch self { case .root(let threadContext), .reply(let threadContext), .leaf(let threadContext): return threadContext.status } } } } extension StatusItem.Thread { class Context: Hashable { let status: ManagedObjectRecord var displayUpperConversationLink: Bool var displayBottomConversationLink: Bool init( status: ManagedObjectRecord, displayUpperConversationLink: Bool = false, displayBottomConversationLink: Bool = false ) { self.status = status self.displayUpperConversationLink = displayUpperConversationLink self.displayBottomConversationLink = displayBottomConversationLink } static func == (lhs: StatusItem.Thread.Context, rhs: StatusItem.Thread.Context) -> Bool { return lhs.status == rhs.status && lhs.displayUpperConversationLink == rhs.displayUpperConversationLink && lhs.displayBottomConversationLink == rhs.displayBottomConversationLink } func hash(into hasher: inout Hasher) { hasher.combine(status) hasher.combine(displayUpperConversationLink) hasher.combine(displayBottomConversationLink) } } }