From 9f0176350c86eacaeef112c756e9f9fc2ca3361d Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Mon, 6 Feb 2023 18:10:38 -0500 Subject: [PATCH] Cleanup TuskerNavigationDelegate --- Tusker/TuskerNavigationDelegate.swift | 26 +++---------------- ...ActionNotificationGroupTableViewCell.swift | 7 ++--- ...FollowNotificationGroupTableViewCell.swift | 4 ++- .../PollFinishedTableViewCell.swift | 5 ++-- ...atusUpdatedNotificationTableViewCell.swift | 5 ++-- ...ersationMainStatusCollectionViewCell.swift | 4 +-- 6 files changed, 14 insertions(+), 37 deletions(-) diff --git a/Tusker/TuskerNavigationDelegate.swift b/Tusker/TuskerNavigationDelegate.swift index 61b93c3e..1c35e76a 100644 --- a/Tusker/TuskerNavigationDelegate.swift +++ b/Tusker/TuskerNavigationDelegate.swift @@ -12,8 +12,6 @@ import Pachyderm protocol TuskerNavigationDelegate: UIViewController, ToastableViewController { var apiController: MastodonController! { get } - - func conversation(mainStatusID: String, state: CollapseState) -> ConversationViewController } extension TuskerNavigationDelegate { @@ -82,16 +80,12 @@ extension TuskerNavigationDelegate { } } - func conversation(mainStatusID: String, state: CollapseState) -> ConversationViewController { - return ConversationViewController(for: mainStatusID, state: state, mastodonController: apiController) - } - func selected(status statusID: String) { self.selected(status: statusID, state: .unknown) } func selected(status statusID: String, state: CollapseState) { - show(conversation(mainStatusID: statusID, state: state), sender: self) + show(ConversationViewController(for: statusID, state: state, mastodonController: apiController), sender: self) } func compose(editing draft: Draft, animated: Bool = true) { @@ -119,15 +113,11 @@ extension TuskerNavigationDelegate { compose(editing: draft, animated: animated) } - func loadingLargeImage(url: URL, cache: ImageCache, description: String?, animatingFrom sourceView: UIImageView) -> LoadingLargeImageViewController { + func showLoadingLargeImage(url: URL, cache: ImageCache, description: String?, animatingFrom sourceView: UIImageView) { let vc = LoadingLargeImageViewController(url: url, cache: cache, imageDescription: description) vc.animationSourceView = sourceView vc.transitioningDelegate = self - return vc - } - - func showLoadingLargeImage(url: URL, cache: ImageCache, description: String?, animatingFrom sourceView: UIImageView) { - present(loadingLargeImage(url: url, cache: cache, description: description, animatingFrom: sourceView), animated: true) + present(vc, animated: true) } func gallery(attachments: [Attachment], sourceViews: [UIImageView?], startIndex: Int) -> GalleryViewController { @@ -183,16 +173,6 @@ extension TuskerNavigationDelegate { present(vc, animated: true) } - func showFollowedByList(accountIDs: [String]) { - let vc = AccountListViewController(accountIDs: accountIDs, mastodonController: apiController) - vc.title = NSLocalizedString("Followed By", comment: "followed by accounts list title") - show(vc, sender: self) - } - - func statusActionAccountList(action: StatusActionAccountListViewController.ActionType, statusID: String, statusState state: CollapseState, accountIDs: [String]?) -> StatusActionAccountListViewController { - return StatusActionAccountListViewController(actionType: action, statusID: statusID, statusState: state, accountIDs: accountIDs, mastodonController: apiController) - } - } enum PopoverSource { diff --git a/Tusker/Views/Notifications/ActionNotificationGroupTableViewCell.swift b/Tusker/Views/Notifications/ActionNotificationGroupTableViewCell.swift index 53d29537..26e47322 100644 --- a/Tusker/Views/Notifications/ActionNotificationGroupTableViewCell.swift +++ b/Tusker/Views/Notifications/ActionNotificationGroupTableViewCell.swift @@ -263,7 +263,7 @@ extension ActionNotificationGroupTableViewCell: SelectableTableViewCell { default: fatalError() } - let vc = delegate.statusActionAccountList(action: action, statusID: statusID, statusState: .unknown, accountIDs: accountIDs) + let vc = StatusActionAccountListViewController(actionType: action, statusID: statusID, statusState: .unknown, accountIDs: accountIDs, mastodonController: mastodonController) vc.showInacurateCountWarning = false delegate.show(vc) } @@ -272,9 +272,6 @@ extension ActionNotificationGroupTableViewCell: SelectableTableViewCell { extension ActionNotificationGroupTableViewCell: MenuPreviewProvider { func getPreviewProviders(for location: CGPoint, sourceViewController: UIViewController) -> PreviewProviders? { return (content: { - guard let delegate = self.delegate else { - return nil - } let notifications = self.group.notifications let accountIDs = notifications.map { $0.account.id } let action: StatusActionAccountListViewController.ActionType @@ -286,7 +283,7 @@ extension ActionNotificationGroupTableViewCell: MenuPreviewProvider { default: fatalError() } - let vc = delegate.statusActionAccountList(action: action, statusID: self.statusID, statusState: .unknown, accountIDs: accountIDs) + let vc = StatusActionAccountListViewController(actionType: action, statusID: self.statusID, statusState: .unknown, accountIDs: accountIDs, mastodonController: self.mastodonController) vc.showInacurateCountWarning = false return vc }, actions: { diff --git a/Tusker/Views/Notifications/FollowNotificationGroupTableViewCell.swift b/Tusker/Views/Notifications/FollowNotificationGroupTableViewCell.swift index f7fe1518..404d2feb 100644 --- a/Tusker/Views/Notifications/FollowNotificationGroupTableViewCell.swift +++ b/Tusker/Views/Notifications/FollowNotificationGroupTableViewCell.swift @@ -213,7 +213,9 @@ extension FollowNotificationGroupTableViewCell: SelectableTableViewCell { case 1: delegate?.selected(account: accountIDs.first!) default: - delegate?.showFollowedByList(accountIDs: accountIDs) + let vc = AccountListViewController(accountIDs: accountIDs, mastodonController: mastodonController) + vc.title = NSLocalizedString("Followed By", comment: "followed by accounts list title") + delegate?.show(vc) } } } diff --git a/Tusker/Views/Notifications/PollFinishedTableViewCell.swift b/Tusker/Views/Notifications/PollFinishedTableViewCell.swift index 9d1d8ff7..f1e77ddd 100644 --- a/Tusker/Views/Notifications/PollFinishedTableViewCell.swift +++ b/Tusker/Views/Notifications/PollFinishedTableViewCell.swift @@ -120,8 +120,7 @@ extension PollFinishedTableViewCell: SelectableTableViewCell { let status = notification?.status else { return } - let vc = delegate.conversation(mainStatusID: status.id, state: .unknown) - delegate.show(vc) + delegate.selected(status: status.id) } } @@ -133,7 +132,7 @@ extension PollFinishedTableViewCell: MenuPreviewProvider { return nil } return (content: { - delegate.conversation(mainStatusID: statusID, state: .unknown) + ConversationViewController(for: statusID, state: .unknown, mastodonController: delegate.apiController) }, actions: { delegate.actionsForStatus(status, source: .view(self)) }) diff --git a/Tusker/Views/Notifications/StatusUpdatedNotificationTableViewCell.swift b/Tusker/Views/Notifications/StatusUpdatedNotificationTableViewCell.swift index 48d90f00..844e325d 100644 --- a/Tusker/Views/Notifications/StatusUpdatedNotificationTableViewCell.swift +++ b/Tusker/Views/Notifications/StatusUpdatedNotificationTableViewCell.swift @@ -109,8 +109,7 @@ extension StatusUpdatedNotificationTableViewCell: SelectableTableViewCell { let status = notification?.status else { return } - let vc = delegate.conversation(mainStatusID: status.id, state: .unknown) - delegate.show(vc) + delegate.selected(status: status.id) } } @@ -122,7 +121,7 @@ extension StatusUpdatedNotificationTableViewCell: MenuPreviewProvider { return nil } return (content: { - delegate.conversation(mainStatusID: statusID, state: .unknown) + ConversationViewController(for: statusID, state: .unknown, mastodonController: delegate.apiController) }, actions: { delegate.actionsForStatus(status, source: .view(self)) }) diff --git a/Tusker/Views/Status/ConversationMainStatusCollectionViewCell.swift b/Tusker/Views/Status/ConversationMainStatusCollectionViewCell.swift index 279c7d26..b84a35fd 100644 --- a/Tusker/Views/Status/ConversationMainStatusCollectionViewCell.swift +++ b/Tusker/Views/Status/ConversationMainStatusCollectionViewCell.swift @@ -410,7 +410,7 @@ class ConversationMainStatusCollectionViewCell: UICollectionViewListCell, Status guard let delegate else { return } - let vc = delegate.statusActionAccountList(action: .favorite, statusID: statusID, statusState: statusState.copy(), accountIDs: nil) + let vc = StatusActionAccountListViewController(actionType: .favorite, statusID: statusID, statusState: statusState.copy(), accountIDs: nil, mastodonController: mastodonController) // TODO: only show warning if the instance isn't the logged in one vc.showInacurateCountWarning = true delegate.show(vc) @@ -420,7 +420,7 @@ class ConversationMainStatusCollectionViewCell: UICollectionViewListCell, Status guard let delegate else { return } - let vc = delegate.statusActionAccountList(action: .reblog, statusID: statusID, statusState: statusState.copy(), accountIDs: nil) + let vc = StatusActionAccountListViewController(actionType: .favorite, statusID: statusID, statusState: statusState.copy(), accountIDs: nil, mastodonController: mastodonController) vc.showInacurateCountWarning = true delegate.show(vc) }