From cd6bdead013b94371e27699d67f519c8bb23b7b5 Mon Sep 17 00:00:00 2001 From: Jed Fox Date: Thu, 15 Dec 2022 07:39:05 -0500 Subject: [PATCH] DispatchQueue.main.async --- ...Provider+StatusTableViewCellDelegate.swift | 68 +++++++++---------- 1 file changed, 33 insertions(+), 35 deletions(-) diff --git a/Mastodon/Protocol/Provider/DataSourceProvider+StatusTableViewCellDelegate.swift b/Mastodon/Protocol/Provider/DataSourceProvider+StatusTableViewCellDelegate.swift index 0521a3486..3fa1a4256 100644 --- a/Mastodon/Protocol/Provider/DataSourceProvider+StatusTableViewCellDelegate.swift +++ b/Mastodon/Protocol/Provider/DataSourceProvider+StatusTableViewCellDelegate.swift @@ -195,52 +195,50 @@ extension StatusTableViewCellDelegate where Self: DataSourceProvider & AuthConte ) { _ in UIPasteboard.general.url = url }, + UIAction( title: L10n.Common.Controls.Actions.share, image: Asset.Arrow.squareAndArrowUp.image.withRenderingMode(.alwaysTemplate) ) { _ in - Task { - await MainActor.run { - let activityViewController = UIActivityViewController( - activityItems: [ - URLActivityItemWithMetadata(url: url) { metadata in - metadata.title = card.title - - if let image = card.imageURL { - metadata.iconProvider = ImageProvider(url: image, filter: nil).itemProvider - } + DispatchQueue.main.async { + let activityViewController = UIActivityViewController( + activityItems: [ + URLActivityItemWithMetadata(url: url) { metadata in + metadata.title = card.title + + if let image = card.imageURL { + metadata.iconProvider = ImageProvider(url: image, filter: nil).itemProvider } - ], - applicationActivities: [] - ) - self.coordinator.present( - scene: .activityViewController( - activityViewController: activityViewController, - sourceView: statusCardControl, barButtonItem: nil - ), - from: self, - transition: .activityViewControllerPresent(animated: true) - ) - } + } + ], + applicationActivities: [] + ) + self.coordinator.present( + scene: .activityViewController( + activityViewController: activityViewController, + sourceView: statusCardControl, barButtonItem: nil + ), + from: self, + transition: .activityViewControllerPresent(animated: true) + ) } }, + UIAction( title: L10n.Common.Controls.Status.Actions.shareLinkInPost, image: Asset.ObjectsAndTools.squareAndPencil.image.withRenderingMode(.alwaysTemplate) ) { _ in - Task { - await MainActor.run { - self.coordinator.present( - scene: .compose(viewModel: ComposeViewModel( - context: self.context, - authContext: self.authContext, - destination: .topLevel, - initialContent: L10n.Common.Controls.Status.linkViaUser(url.absoluteString, "@" + (statusView.viewModel.authorUsername ?? "")) - )), - from: self, - transition: .modal(animated: true) - ) - } + DispatchQueue.main.async { + self.coordinator.present( + scene: .compose(viewModel: ComposeViewModel( + context: self.context, + authContext: self.authContext, + destination: .topLevel, + initialContent: L10n.Common.Controls.Status.linkViaUser(url.absoluteString, "@" + (statusView.viewModel.authorUsername ?? "")) + )), + from: self, + transition: .modal(animated: true) + ) } } ])