Fix crash when toggling collapse in Trending Posts

Closes #262
This commit is contained in:
Shadowfacts 2022-11-22 11:47:57 -05:00
parent 3e7cb443fa
commit 49f1d6339f
2 changed files with 22 additions and 1 deletions

View File

@ -8,7 +8,7 @@
import Foundation import Foundation
public class StatusState: Equatable, Hashable { public class StatusState: Equatable {
public var collapsible: Bool? public var collapsible: Bool?
public var collapsed: Bool? public var collapsed: Bool?

View File

@ -122,6 +122,27 @@ extension TrendingStatusesViewController {
case status(id: String, state: StatusState) case status(id: String, state: StatusState)
case loadingIndicator 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 { var hideSeparators: Bool {
if case .loadingIndicator = self { if case .loadingIndicator = self {
return true return true