From 49f1d6339f52731a6d5715f4834911f6c3708cc7 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Tue, 22 Nov 2022 11:47:57 -0500 Subject: [PATCH] Fix crash when toggling collapse in Trending Posts Closes #262 --- .../Pachyderm/Utilities/StatusState.swift | 2 +- .../TrendingStatusesViewController.swift | 21 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/Pachyderm/Sources/Pachyderm/Utilities/StatusState.swift b/Pachyderm/Sources/Pachyderm/Utilities/StatusState.swift index c3b380c9..3bb71e9b 100644 --- a/Pachyderm/Sources/Pachyderm/Utilities/StatusState.swift +++ b/Pachyderm/Sources/Pachyderm/Utilities/StatusState.swift @@ -8,7 +8,7 @@ import Foundation -public class StatusState: Equatable, Hashable { +public class StatusState: Equatable { public var collapsible: Bool? public var collapsed: Bool? diff --git a/Tusker/Screens/Explore/TrendingStatusesViewController.swift b/Tusker/Screens/Explore/TrendingStatusesViewController.swift index be39dc2e..56f10fb3 100644 --- a/Tusker/Screens/Explore/TrendingStatusesViewController.swift +++ b/Tusker/Screens/Explore/TrendingStatusesViewController.swift @@ -122,6 +122,27 @@ extension TrendingStatusesViewController { case status(id: String, state: StatusState) case loadingIndicator + static func ==(lhs: Item, rhs: Item) -> Bool { + switch (lhs, rhs) { + case (.status(id: let a, state: _), .status(id: let b, state: _)): + return a == b + case (.loadingIndicator, .loadingIndicator): + return true + default: + return false + } + } + + func hash(into hasher: inout Hasher) { + switch self { + case .status(id: let id, state: _): + hasher.combine(0) + hasher.combine(id) + case .loadingIndicator: + hasher.combine(1) + } + } + var hideSeparators: Bool { if case .loadingIndicator = self { return true