Naming consistency and improve conformance (a bit) (#625)

This commit is contained in:
Doug
2023-02-24 11:44:41 +00:00
committed by GitHub
parent a3c7c47a69
commit 21bd37c0b1
7 changed files with 63 additions and 57 deletions
@@ -19,25 +19,31 @@ import Foundation
struct CollapsibleTimelineItem: RoomTimelineItemProtocol, Identifiable, Hashable {
let id: String
let items: [RoomTimelineItemProtocol]
let itemIDs: [String]
init(items: [RoomTimelineItemProtocol]) {
guard let firstItem = items.first else {
self.items = items
itemIDs = items.map(\.id)
guard let firstItemID = itemIDs.first else {
fatalError()
}
self.items = items
id = firstItem.id
id = firstItemID
}
// MARK: - Equatable
static func == (lhs: CollapsibleTimelineItem, rhs: CollapsibleTimelineItem) -> Bool {
lhs.id == rhs.id
// Technically not a correct implementation of equality as the items themselves could be updated.
lhs.id == rhs.id && lhs.itemIDs == rhs.itemIDs
}
// MARK: - Hashable
func hash(into hasher: inout Hasher) {
// Technically not a correct implementation of hashing as the items themselves could be updated.
hasher.combine(id)
hasher.combine(itemIDs)
}
}