diff --git a/Packages/Models/Sources/Models/Status.swift b/Packages/Models/Sources/Models/Status.swift index 00f11d7d..695ac58d 100644 --- a/Packages/Models/Sources/Models/Status.swift +++ b/Packages/Models/Sources/Models/Status.swift @@ -35,6 +35,7 @@ public protocol AnyStatus { var filtered: [Filtered]? { get } var sensitive: Bool { get } var language: String? { get } + var isHidden: Bool { get } } public struct StatusViewId: Hashable { @@ -84,6 +85,10 @@ public final class Status: AnyStatus, Codable, Identifiable, Equatable, Hashable public let filtered: [Filtered]? public let sensitive: Bool public let language: String? + + public var isHidden: Bool { + filtered?.first?.filter.filterAction == .hide + } public init(id: String, content: HTMLString, account: Account, createdAt: ServerDate, editedAt: ServerDate?, reblog: ReblogStatus?, mediaAttachments: [MediaAttachment], mentions: [Mention], repliesCount: Int, reblogsCount: Int, favouritesCount: Int, card: Card?, favourited: Bool?, reblogged: Bool?, pinned: Bool?, bookmarked: Bool?, emojis: [Emoji], url: String?, application: Application?, inReplyToId: String?, inReplyToAccountId: String?, visibility: Visibility, poll: Poll?, spoilerText: HTMLString, filtered: [Filtered]?, sensitive: Bool, language: String?) { self.id = id @@ -221,6 +226,10 @@ public final class ReblogStatus: AnyStatus, Codable, Identifiable, Equatable, Ha public let filtered: [Filtered]? public let sensitive: Bool public let language: String? + + public var isHidden: Bool { + filtered?.first?.filter.filterAction == .hide + } public init(id: String, content: HTMLString, account: Account, createdAt: ServerDate, editedAt: ServerDate?, mediaAttachments: [MediaAttachment], mentions: [Mention], repliesCount: Int, reblogsCount: Int, favouritesCount: Int, card: Card?, favourited: Bool?, reblogged: Bool?, pinned: Bool?, bookmarked: Bool?, emojis: [Emoji], url: String?, application: Application? = nil, inReplyToId: String?, inReplyToAccountId: String?, visibility: Visibility, poll: Poll?, spoilerText: HTMLString, filtered: [Filtered]?, sensitive: Bool, language: String?) { self.id = id diff --git a/Packages/Status/Sources/Status/List/StatusesListView.swift b/Packages/Status/Sources/Status/List/StatusesListView.swift index e970881e..db3c1c15 100644 --- a/Packages/Status/Sources/Status/List/StatusesListView.swift +++ b/Packages/Status/Sources/Status/List/StatusesListView.swift @@ -48,17 +48,19 @@ public struct StatusesListView: View where Fetcher: StatusesFetcher { case let .display(statuses, nextPageState): ForEach(statuses, id: \.viewId) { status in - StatusRowView(viewModel: StatusRowViewModel(status: status, - client: client, - routerPath: routerPath, - isRemote: isRemote)) - .id(status.id) - .onAppear { - fetcher.statusDidAppear(status: status) - } - .onDisappear { - fetcher.statusDidDisappear(status: status) - } + if !status.isHidden { + StatusRowView(viewModel: StatusRowViewModel(status: status, + client: client, + routerPath: routerPath, + isRemote: isRemote)) + .id(status.id) + .onAppear { + fetcher.statusDidAppear(status: status) + } + .onDisappear { + fetcher.statusDidDisappear(status: status) + } + } } switch nextPageState { case .hasNextPage: diff --git a/Packages/Timeline/Sources/Timeline/actors/TimelineDatasource.swift b/Packages/Timeline/Sources/Timeline/actors/TimelineDatasource.swift index 8c28899c..3f554087 100644 --- a/Packages/Timeline/Sources/Timeline/actors/TimelineDatasource.swift +++ b/Packages/Timeline/Sources/Timeline/actors/TimelineDatasource.swift @@ -9,7 +9,7 @@ actor TimelineDatasource { } func get() -> [Status] { - statuses.filter { $0.filtered?.first?.filter.filterAction != .hide } + statuses } func count() -> Int {