Fix preview action on iPad Explore screen not working

This commit is contained in:
Shadowfacts 2023-01-22 14:12:05 -05:00
parent e8b7446117
commit 2ea8e9cf1e
1 changed files with 15 additions and 2 deletions

View File

@ -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(_):