Fix CW cannot be hidden (IOS-176)

This commit is contained in:
Marcus Kida 2023-11-28 10:46:24 +01:00
parent 9fed54db1f
commit 45accb29e6
No known key found for this signature in database
GPG Key ID: 19FF64E08013CA40
4 changed files with 26 additions and 8 deletions

View File

@ -150,7 +150,7 @@ extension DataSourceFacade {
@MainActor
static func responseToMenuAction(
dependency: UIViewController & NeedsDependency & AuthContextProvider,
dependency: UIViewController & NeedsDependency & AuthContextProvider & DataSourceProvider,
action: MastodonMenu.Action,
menuContext: MenuContext
) async throws {
@ -389,13 +389,15 @@ extension DataSourceFacade {
extension DataSourceFacade {
static func responseToToggleSensitiveAction(
dependency: NeedsDependency,
dependency: NeedsDependency & DataSourceProvider,
status: MastodonStatus
) async throws {
try await dependency.context.managedObjectContext.perform {
let _status = status.reblog ?? status
_status.isSensitiveToggled = !_status.isSensitiveToggled
}
let _status = status.reblog ?? status
let newStatus: MastodonStatus = .fromEntity(_status.entity)
newStatus.isSensitiveToggled = !_status.isSensitiveToggled
dependency.update(status: newStatus)
}
}

View File

@ -16,6 +16,7 @@ import MastodonLocalization
import CoreDataStack
import TabBarPager
import XLPagerTabStrip
import MastodonSDK
protocol ProfileViewModelEditable {
var isEdited: Bool { get }
@ -940,3 +941,14 @@ private extension ProfileViewController {
authContext.mastodonAuthenticationBox.authentication.instance(in: context.managedObjectContext)
}
}
extension ProfileViewController: DataSourceProvider {
func item(from source: DataSourceItem.Source) async -> DataSourceItem? {
assertionFailure("Implement not required in this class")
return nil
}
func update(status: MastodonStatus) {
assertionFailure("Implement not required in this class")
}
}

View File

@ -56,13 +56,15 @@ extension MastodonFeed: Hashable {
public static func == (lhs: MastodonFeed, rhs: MastodonFeed) -> Bool {
lhs.id == rhs.id &&
lhs.status?.entity == rhs.status?.entity &&
lhs.status?.reblog?.entity == rhs.status?.reblog?.entity
lhs.status?.reblog?.entity == rhs.status?.reblog?.entity &&
lhs.status?.isSensitiveToggled == rhs.status?.isSensitiveToggled
}
public func hash(into hasher: inout Hasher) {
hasher.combine(id)
hasher.combine(status?.entity)
hasher.combine(status?.reblog?.entity)
hasher.combine(status?.isSensitiveToggled)
}
}

View File

@ -37,12 +37,14 @@ extension MastodonStatus {
extension MastodonStatus: Hashable {
public static func == (lhs: MastodonStatus, rhs: MastodonStatus) -> Bool {
lhs.entity == rhs.entity &&
lhs.reblog?.entity == rhs.reblog?.entity
lhs.reblog?.entity == rhs.reblog?.entity &&
lhs.isSensitiveToggled == rhs.isSensitiveToggled
}
public func hash(into hasher: inout Hasher) {
hasher.combine(entity)
hasher.combine(reblog?.entity)
hasher.combine(isSensitiveToggled)
}
}