From 2ea8e9cf1efe580b151ce2863d11db44fe37b980 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Sun, 22 Jan 2023 14:12:05 -0500 Subject: [PATCH] Fix preview action on iPad Explore screen not working --- .../Screens/Search/SearchViewController.swift | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/Tusker/Screens/Search/SearchViewController.swift b/Tusker/Screens/Search/SearchViewController.swift index 2fc4a674..1ce86125 100644 --- a/Tusker/Screens/Search/SearchViewController.swift +++ b/Tusker/Screens/Search/SearchViewController.swift @@ -321,8 +321,17 @@ extension SearchViewController: UICollectionViewDelegate { UIMenu(children: self.actionsForTrendingLink(card: card)) } - default: - fatalError("todo") + case let .status(id, state): + guard let status = mastodonController.persistentContainer.status(for: id) else { + return nil + } + let cell = collectionView.cellForItem(at: indexPath)! + return UIContextMenuConfiguration { + ConversationViewController(for: id, state: state.copy(), mastodonController: self.mastodonController) + } actionProvider: { _ in + UIMenu(children: self.actionsForStatus(status, source: .view(cell))) + } + } } @@ -335,6 +344,10 @@ extension SearchViewController: UICollectionViewDelegate { return self.collectionView(collectionView, contextMenuConfigurationForItemAt: indexPaths[0], point: point) } + func collectionView(_ collectionView: UICollectionView, willPerformPreviewActionForMenuWith configuration: UIContextMenuConfiguration, animator: UIContextMenuInteractionCommitAnimating) { + MenuPreviewHelper.willPerformPreviewAction(animator: animator, presenter: self) + } + func collectionView(_ collectionView: UICollectionView, contextMenuConfiguration configuration: UIContextMenuConfiguration, highlightPreviewForItemAt indexPath: IndexPath) -> UITargetedPreview? { switch dataSource.itemIdentifier(for: indexPath) { case .link(_):