diff --git a/Mastodon/Diffiable/Section/NotificationSection.swift b/Mastodon/Diffiable/Section/NotificationSection.swift index 558f94dd9..ead5d48f8 100644 --- a/Mastodon/Diffiable/Section/NotificationSection.swift +++ b/Mastodon/Diffiable/Section/NotificationSection.swift @@ -50,7 +50,6 @@ extension NotificationSection { let frame = CGRect(x: 0, y: 0, width: tableView.readableContentGuide.layoutFrame.width - NotificationStatusTableViewCell.statusPadding.left - NotificationStatusTableViewCell.statusPadding.right, height: tableView.readableContentGuide.layoutFrame.height) StatusSection.configure( cell: cell, - indexPath: indexPath, dependency: dependency, readableLayoutFrame: frame, timestampUpdatePublisher: timestampUpdatePublisher, diff --git a/Mastodon/Diffiable/Section/ReportSection.swift b/Mastodon/Diffiable/Section/ReportSection.swift index 07321be96..6faaae6c2 100644 --- a/Mastodon/Diffiable/Section/ReportSection.swift +++ b/Mastodon/Diffiable/Section/ReportSection.swift @@ -41,7 +41,6 @@ extension ReportSection { let status = managedObjectContext.object(with: objectID) as! Status StatusSection.configure( cell: cell, - indexPath: indexPath, dependency: dependency, readableLayoutFrame: tableView.readableContentGuide.layoutFrame, timestampUpdatePublisher: timestampUpdatePublisher, diff --git a/Mastodon/Diffiable/Section/StatusSection.swift b/Mastodon/Diffiable/Section/StatusSection.swift index b5aadbf16..cb38ec8ab 100644 --- a/Mastodon/Diffiable/Section/StatusSection.swift +++ b/Mastodon/Diffiable/Section/StatusSection.swift @@ -49,7 +49,6 @@ extension StatusSection { let timelineIndex = managedObjectContext.object(with: objectID) as! HomeTimelineIndex StatusSection.configure( cell: cell, - indexPath: indexPath, dependency: dependency, readableLayoutFrame: tableView.readableContentGuide.layoutFrame, timestampUpdatePublisher: timestampUpdatePublisher, @@ -72,7 +71,6 @@ extension StatusSection { let status = managedObjectContext.object(with: objectID) as! Status StatusSection.configure( cell: cell, - indexPath: indexPath, dependency: dependency, readableLayoutFrame: tableView.readableContentGuide.layoutFrame, timestampUpdatePublisher: timestampUpdatePublisher, @@ -138,7 +136,6 @@ extension StatusSection { static func configure( cell: StatusCell, - indexPath: IndexPath, dependency: NeedsDependency, readableLayoutFrame: CGRect?, timestampUpdatePublisher: AnyPublisher, @@ -407,7 +404,6 @@ extension StatusSection { // toolbar StatusSection.configureActionToolBar( cell: statusTableViewCell, - indexPath: indexPath, dependency: dependency, status: status, requestUserID: requestUserID @@ -438,7 +434,6 @@ extension StatusSection { guard let statusTableViewCell = cell as? StatusTableViewCell else { return } StatusSection.configureActionToolBar( cell: statusTableViewCell, - indexPath: indexPath, dependency: dependency, status: status, requestUserID: requestUserID @@ -597,7 +592,6 @@ extension StatusSection { static func configureActionToolBar( cell: StatusTableViewCell, - indexPath: IndexPath, dependency: NeedsDependency, status: Status, requestUserID: String @@ -644,10 +638,10 @@ extension StatusSection { case .none: break } - StatusSection.setupStatusMoreButtonMenu(cell: cell, indexPath: indexPath, dependency: dependency, status: status) + StatusSection.setupStatusMoreButtonMenu(cell: cell, dependency: dependency, status: status) } .store(in: &cell.disposeBag) - self.setupStatusMoreButtonMenu(cell: cell, indexPath: indexPath, dependency: dependency, status: status) + self.setupStatusMoreButtonMenu(cell: cell, dependency: dependency, status: status) } static func configurePoll( @@ -777,7 +771,6 @@ extension StatusSection { private static func setupStatusMoreButtonMenu( cell: StatusTableViewCell, - indexPath: IndexPath, dependency: NeedsDependency, status: Status) { @@ -802,7 +795,6 @@ extension StatusSection { isDomainBlocking: isDomainBlocking, provider: userProvider, cell: cell, - indexPath: indexPath, sourceView: cell.statusView.actionToolbarContainer.moreButton, barButtonItem: nil, shareUser: nil, diff --git a/Mastodon/Protocol/StatusProvider/StatusProvider+UITableViewDelegate.swift b/Mastodon/Protocol/StatusProvider/StatusProvider+UITableViewDelegate.swift index 46e4c5ab5..98fa2d2cd 100644 --- a/Mastodon/Protocol/StatusProvider/StatusProvider+UITableViewDelegate.swift +++ b/Mastodon/Protocol/StatusProvider/StatusProvider+UITableViewDelegate.swift @@ -114,7 +114,7 @@ extension StatusTableViewCellDelegate where Self: StatusProvider { guard let imagePreviewPresentableCell = tableView.cellForRow(at: indexPath) as? ImagePreviewPresentableCell else { return nil } guard imagePreviewPresentableCell.isRevealing else { return nil } - let status = status(for: nil, indexPath: indexPath) + let status = self.status(for: nil, indexPath: indexPath) return contextMenuConfiguration(tableView, status: status, imagePreviewPresentableCell: imagePreviewPresentableCell, contextMenuConfigurationForRowAt: indexPath, point: point) } @@ -260,7 +260,7 @@ extension StatusTableViewCellDelegate where Self: StatusProvider { guard index < imageViews.count else { return } let imageView = imageViews[index] - let status = status(for: nil, indexPath: indexPath) + let status = self.status(for: nil, indexPath: indexPath) let initialFrame: CGRect? = { guard let previewViewController = animator.previewViewController else { return nil } return UIView.findContextMenuPreviewFrameInWindow(previewController: previewViewController) diff --git a/Mastodon/Protocol/UserProvider/UserProvider.swift b/Mastodon/Protocol/UserProvider/UserProvider.swift index 58c7ba5f7..f9939c740 100644 --- a/Mastodon/Protocol/UserProvider/UserProvider.swift +++ b/Mastodon/Protocol/UserProvider/UserProvider.swift @@ -14,14 +14,14 @@ protocol UserProvider: NeedsDependency & DisposeBagCollectable & UIViewControlle // async func mastodonUser() -> Future - func mastodonUser(for cell: UITableViewCell?, indexPath: IndexPath?) -> Future + func mastodonUser(for cell: UITableViewCell?) -> Future } extension UserProvider where Self: StatusProvider { - func mastodonUser(for cell: UITableViewCell?, indexPath: IndexPath?) -> Future { + func mastodonUser(for cell: UITableViewCell?) -> Future { Future { [weak self] promise in guard let self = self else { return } - self.status(for: cell, indexPath: indexPath) + self.status(for: cell, indexPath: nil) .sink { status in promise(.success(status?.authorForUserProvider)) } diff --git a/Mastodon/Protocol/UserProvider/UserProviderFacade.swift b/Mastodon/Protocol/UserProvider/UserProviderFacade.swift index dccfd4605..2aeff0e09 100644 --- a/Mastodon/Protocol/UserProvider/UserProviderFacade.swift +++ b/Mastodon/Protocol/UserProvider/UserProviderFacade.swift @@ -54,19 +54,18 @@ extension UserProviderFacade { extension UserProviderFacade { static func toggleUserBlockRelationship( provider: UserProvider, - cell: UITableViewCell?, - indexPath: IndexPath? + cell: UITableViewCell? ) -> AnyPublisher, Error> { // prepare authentication guard let activeMastodonAuthenticationBox = provider.context.authenticationService.activeMastodonAuthenticationBox.value else { assertionFailure() return Fail(error: APIService.APIError.implicit(.authenticationMissing)).eraseToAnyPublisher() } - if let cell = cell, let indexPath = indexPath { + if let cell = cell { return _toggleUserBlockRelationship( context: provider.context, activeMastodonAuthenticationBox: activeMastodonAuthenticationBox, - mastodonUser: provider.mastodonUser(for: cell, indexPath: indexPath).eraseToAnyPublisher() + mastodonUser: provider.mastodonUser(for: cell).eraseToAnyPublisher() ) } else { return _toggleUserBlockRelationship( @@ -101,19 +100,18 @@ extension UserProviderFacade { extension UserProviderFacade { static func toggleUserMuteRelationship( provider: UserProvider, - cell: UITableViewCell?, - indexPath: IndexPath? + cell: UITableViewCell? ) -> AnyPublisher, Error> { // prepare authentication guard let activeMastodonAuthenticationBox = provider.context.authenticationService.activeMastodonAuthenticationBox.value else { assertionFailure() return Fail(error: APIService.APIError.implicit(.authenticationMissing)).eraseToAnyPublisher() } - if let cell = cell, let indexPath = indexPath { + if let cell = cell { return _toggleUserMuteRelationship( context: provider.context, activeMastodonAuthenticationBox: activeMastodonAuthenticationBox, - mastodonUser: provider.mastodonUser(for: cell, indexPath: indexPath).eraseToAnyPublisher() + mastodonUser: provider.mastodonUser(for: cell).eraseToAnyPublisher() ) } else { return _toggleUserMuteRelationship( @@ -155,7 +153,6 @@ extension UserProviderFacade { isDomainBlocking: Bool, provider: UserProvider, cell: UITableViewCell?, - indexPath: IndexPath?, sourceView: UIView?, barButtonItem: UIBarButtonItem?, shareUser: MastodonUser?, @@ -176,8 +173,7 @@ extension UserProviderFacade { UserProviderFacade.toggleUserMuteRelationship( provider: provider, - cell: cell, - indexPath: indexPath + cell: cell ) .sink { _ in // do nothing @@ -205,8 +201,7 @@ extension UserProviderFacade { UserProviderFacade.toggleUserBlockRelationship( provider: provider, - cell: cell, - indexPath: indexPath + cell: cell ) .sink { _ in // do nothing @@ -246,7 +241,7 @@ extension UserProviderFacade { if isDomainBlocking { let unblockDomainAction = UIAction(title: L10n.Common.Controls.Actions.unblockDomain(mastodonUser.domainFromAcct), image: UIImage(systemName: "nosign"), identifier: nil, discoverabilityTitle: nil, attributes: [], state: .off) { [weak provider] _ in guard let provider = provider else { return } - provider.context.blockDomainService.unblockDomain(userProvider: provider, cell: cell, indexPath: indexPath) + provider.context.blockDomainService.unblockDomain(userProvider: provider, cell: cell) } children.append(unblockDomainAction) } else { @@ -257,7 +252,7 @@ extension UserProviderFacade { } alertController.addAction(cancelAction) let blockDomainAction = UIAlertAction(title: L10n.Common.Alerts.BlockDomain.blockEntireDomain, style: .destructive) { _ in - provider.context.blockDomainService.blockDomain(userProvider: provider, cell: cell, indexPath: indexPath) + provider.context.blockDomainService.blockDomain(userProvider: provider, cell: cell) } alertController.addAction(blockDomainAction) provider.present(alertController, animated: true, completion: nil) diff --git a/Mastodon/Scene/Profile/ProfileViewController+UserProvider.swift b/Mastodon/Scene/Profile/ProfileViewController+UserProvider.swift index be124a0c2..6bfa132b8 100644 --- a/Mastodon/Scene/Profile/ProfileViewController+UserProvider.swift +++ b/Mastodon/Scene/Profile/ProfileViewController+UserProvider.swift @@ -11,7 +11,7 @@ import CoreDataStack import UIKit extension ProfileViewController: UserProvider { - func mastodonUser(for cell: UITableViewCell?, indexPath: IndexPath?) -> Future { + func mastodonUser(for cell: UITableViewCell?) -> Future { return Future { promise in promise(.success(nil)) } diff --git a/Mastodon/Scene/Profile/ProfileViewController.swift b/Mastodon/Scene/Profile/ProfileViewController.swift index 5d819c6b3..521df753b 100644 --- a/Mastodon/Scene/Profile/ProfileViewController.swift +++ b/Mastodon/Scene/Profile/ProfileViewController.swift @@ -399,7 +399,6 @@ extension ProfileViewController { isDomainBlocking: isDomainBlocking, provider: self, cell: nil, - indexPath: nil, sourceView: nil, barButtonItem: self.moreMenuBarButtonItem, shareUser: needsShareAction ? mastodonUser : nil, @@ -787,7 +786,7 @@ extension ProfileViewController: ProfileHeaderViewDelegate { ) let unmuteAction = UIAlertAction(title: L10n.Common.Controls.Firendship.unmute, style: .default) { [weak self] _ in guard let self = self else { return } - UserProviderFacade.toggleUserMuteRelationship(provider: self, cell: nil, indexPath: nil) + UserProviderFacade.toggleUserMuteRelationship(provider: self, cell: nil) .sink { _ in // do nothing } receiveValue: { _ in @@ -809,7 +808,7 @@ extension ProfileViewController: ProfileHeaderViewDelegate { ) let unblockAction = UIAlertAction(title: L10n.Common.Controls.Firendship.unblock, style: .default) { [weak self] _ in guard let self = self else { return } - UserProviderFacade.toggleUserBlockRelationship(provider: self, cell: nil, indexPath: nil) + UserProviderFacade.toggleUserBlockRelationship(provider: self, cell: nil) .sink { _ in // do nothing } receiveValue: { _ in diff --git a/Mastodon/Scene/Search/SearchViewController+Follow.swift b/Mastodon/Scene/Search/SearchViewController+Follow.swift index 6682d846b..a7f7faf90 100644 --- a/Mastodon/Scene/Search/SearchViewController+Follow.swift +++ b/Mastodon/Scene/Search/SearchViewController+Follow.swift @@ -12,7 +12,7 @@ import UIKit extension SearchViewController: UserProvider { - func mastodonUser(for cell: UITableViewCell?, indexPath: IndexPath?) -> Future { + func mastodonUser(for cell: UITableViewCell?) -> Future { return Future { promise in promise(.success(nil)) } @@ -54,7 +54,7 @@ extension SearchViewController: SearchRecommendAccountsCollectionViewCellDelegat ) let unmuteAction = UIAlertAction(title: L10n.Common.Controls.Firendship.unmute, style: .default) { [weak self] _ in guard let self = self else { return } - UserProviderFacade.toggleUserMuteRelationship(provider: self, cell: nil, indexPath: nil) + UserProviderFacade.toggleUserMuteRelationship(provider: self, cell: nil) .sink { _ in // do nothing } receiveValue: { _ in @@ -76,7 +76,7 @@ extension SearchViewController: SearchRecommendAccountsCollectionViewCellDelegat ) let unblockAction = UIAlertAction(title: L10n.Common.Controls.Firendship.unblock, style: .default) { [weak self] _ in guard let self = self else { return } - UserProviderFacade.toggleUserBlockRelationship(provider: self, cell: nil, indexPath: nil) + UserProviderFacade.toggleUserBlockRelationship(provider: self, cell: nil) .sink { _ in // do nothing } receiveValue: { _ in diff --git a/Mastodon/Service/BlockDomainService.swift b/Mastodon/Service/BlockDomainService.swift index 217f1af1f..036083e60 100644 --- a/Mastodon/Service/BlockDomainService.swift +++ b/Mastodon/Service/BlockDomainService.swift @@ -46,16 +46,15 @@ final class BlockDomainService { func blockDomain( userProvider: UserProvider, - cell: UITableViewCell?, - indexPath: IndexPath? + cell: UITableViewCell? ) { guard let activeMastodonAuthenticationBox = userProvider.context.authenticationService.activeMastodonAuthenticationBox.value else { return } guard let context = userProvider.context else { return } var mastodonUser: AnyPublisher - if let cell = cell, let indexPath = indexPath { - mastodonUser = userProvider.mastodonUser(for: cell, indexPath: indexPath).eraseToAnyPublisher() + if let cell = cell { + mastodonUser = userProvider.mastodonUser(for: cell).eraseToAnyPublisher() } else { mastodonUser = userProvider.mastodonUser().eraseToAnyPublisher() } @@ -85,16 +84,15 @@ final class BlockDomainService { func unblockDomain( userProvider: UserProvider, - cell: UITableViewCell?, - indexPath: IndexPath? + cell: UITableViewCell? ) { guard let activeMastodonAuthenticationBox = userProvider.context.authenticationService.activeMastodonAuthenticationBox.value else { return } guard let context = userProvider.context else { return } var mastodonUser: AnyPublisher - if let cell = cell, let indexPath = indexPath { - mastodonUser = userProvider.mastodonUser(for: cell, indexPath: indexPath).eraseToAnyPublisher() + if let cell = cell { + mastodonUser = userProvider.mastodonUser(for: cell).eraseToAnyPublisher() } else { mastodonUser = userProvider.mastodonUser().eraseToAnyPublisher() }