From ca3fd69b62f93f835c611e780de70e2c4a331262 Mon Sep 17 00:00:00 2001 From: Nathan Mattes Date: Thu, 18 Jan 2024 16:59:14 +0100 Subject: [PATCH] [WIP] Preparation to get relationship into menu on notification-screen (IOS-192) --- ...er+NotificationTableViewCellDelegate.swift | 45 ++++++++++++++----- .../View/Content/NotificationView.swift | 1 + 2 files changed, 35 insertions(+), 11 deletions(-) diff --git a/Mastodon/Protocol/Provider/DataSourceProvider+NotificationTableViewCellDelegate.swift b/Mastodon/Protocol/Provider/DataSourceProvider+NotificationTableViewCellDelegate.swift index 850a240db..7d41d27ff 100644 --- a/Mastodon/Protocol/Provider/DataSourceProvider+NotificationTableViewCellDelegate.swift +++ b/Mastodon/Protocol/Provider/DataSourceProvider+NotificationTableViewCellDelegate.swift @@ -31,18 +31,41 @@ extension NotificationTableViewCellDelegate where Self: DataSourceProvider & Aut return } - //TODO: Update Relationship - _ = try await DataSourceFacade.responseToMenuAction( - dependency: self, - action: action, - menuContext: .init( - author: notification.entity.account, - statusViewModel: nil, - button: button, - barButtonItem: nil + // we only allow to mute/block and to report users on notification-screen + switch action { + case .muteUser(_), .blockUser(_): + _ = try await DataSourceFacade.responseToMenuAction( + dependency: self, + action: action, + menuContext: .init( + author: notification.entity.account, + statusViewModel: nil, + button: button, + barButtonItem: nil + ), + completion: { (newRelationship: Mastodon.Entity.Relationship) in + //TODO: Update Relationship. + //TODO: Get Relationship into here, first! + + print(newRelationship) + } ) - ) - } // end Task + case .reportUser(_): + _ = try await DataSourceFacade.responseToMenuAction( + dependency: self, + action: action, + menuContext: .init( + author: notification.entity.account, + statusViewModel: nil, + button: button, + barButtonItem: nil + ) + ) + case .translateStatus(_), .showOriginal, .shareUser(_), .blockDomain(_), .bookmarkStatus(_), .hideReblogs(_), .shareStatus, .deleteStatus, .editStatus, .followUser(_): + // Do Nothing + break + } + } } } diff --git a/MastodonSDK/Sources/MastodonUI/View/Content/NotificationView.swift b/MastodonSDK/Sources/MastodonUI/View/Content/NotificationView.swift index 437a7bb2e..da257f0c0 100644 --- a/MastodonSDK/Sources/MastodonUI/View/Content/NotificationView.swift +++ b/MastodonSDK/Sources/MastodonUI/View/Content/NotificationView.swift @@ -476,6 +476,7 @@ extension NotificationView: AdaptiveContainerView { } extension NotificationView { + @available(*, deprecated, message: "Does way too much") public typealias AuthorMenuContext = StatusAuthorView.AuthorMenuContext public func setupAuthorMenu(menuContext: AuthorMenuContext) -> (UIMenu, [UIAccessibilityCustomAction]) {