Statuses: Cleanup viewId

This commit is contained in:
Thomas Ricouard 2024-01-02 14:06:53 +01:00
parent 924e1b6057
commit 632b3f5734
2 changed files with 2 additions and 17 deletions

View file

@ -8,7 +8,6 @@ public enum Visibility: String, Codable, CaseIterable, Hashable, Equatable, Send
}
public protocol AnyStatus {
var viewId: StatusViewId { get }
var id: String { get }
var content: HTMLString { get }
var account: Account { get }
@ -38,20 +37,9 @@ public protocol AnyStatus {
var isHidden: Bool { get }
}
public struct StatusViewId: Hashable {
let id: String
let editedAt: Date?
}
public extension AnyStatus {
var viewId: StatusViewId {
StatusViewId(id: id, editedAt: editedAt?.asDate)
}
}
public final class Status: AnyStatus, Codable, Identifiable, Equatable, Hashable {
public static func == (lhs: Status, rhs: Status) -> Bool {
lhs.id == rhs.id && lhs.viewId == rhs.viewId
lhs.id == rhs.id && lhs.editedAt?.asDate == rhs.editedAt?.asDate
}
public func hash(into hasher: inout Hasher) {
@ -261,8 +249,6 @@ public final class ReblogStatus: AnyStatus, Codable, Identifiable, Equatable, Ha
}
}
extension StatusViewId: Sendable {}
// Every property in Status is immutable.
extension Status: Sendable {}

View file

@ -47,12 +47,11 @@ public struct StatusesListView<Fetcher>: View where Fetcher: StatusesFetcher {
.listRowSeparator(.hidden)
case let .display(statuses, nextPageState):
ForEach(statuses, id: \.viewId) { status in
ForEach(statuses, id: \.id) { status in
StatusRowView(viewModel: StatusRowViewModel(status: status,
client: client,
routerPath: routerPath,
isRemote: isRemote))
.id(status.id)
.onAppear {
fetcher.statusDidAppear(status: status)
}