DispatchQueue.main.async

This commit is contained in:
Jed Fox 2022-12-15 07:39:05 -05:00
parent 4f8ca8d481
commit cd6bdead01
No known key found for this signature in database
GPG Key ID: 0B61D18EA54B47E1
1 changed files with 33 additions and 35 deletions

View File

@ -195,52 +195,50 @@ extension StatusTableViewCellDelegate where Self: DataSourceProvider & AuthConte
) { _ in ) { _ in
UIPasteboard.general.url = url UIPasteboard.general.url = url
}, },
UIAction( UIAction(
title: L10n.Common.Controls.Actions.share, title: L10n.Common.Controls.Actions.share,
image: Asset.Arrow.squareAndArrowUp.image.withRenderingMode(.alwaysTemplate) image: Asset.Arrow.squareAndArrowUp.image.withRenderingMode(.alwaysTemplate)
) { _ in ) { _ in
Task { DispatchQueue.main.async {
await MainActor.run { let activityViewController = UIActivityViewController(
let activityViewController = UIActivityViewController( activityItems: [
activityItems: [ URLActivityItemWithMetadata(url: url) { metadata in
URLActivityItemWithMetadata(url: url) { metadata in metadata.title = card.title
metadata.title = card.title
if let image = card.imageURL { if let image = card.imageURL {
metadata.iconProvider = ImageProvider(url: image, filter: nil).itemProvider metadata.iconProvider = ImageProvider(url: image, filter: nil).itemProvider
}
} }
], }
applicationActivities: [] ],
) applicationActivities: []
self.coordinator.present( )
scene: .activityViewController( self.coordinator.present(
activityViewController: activityViewController, scene: .activityViewController(
sourceView: statusCardControl, barButtonItem: nil activityViewController: activityViewController,
), sourceView: statusCardControl, barButtonItem: nil
from: self, ),
transition: .activityViewControllerPresent(animated: true) from: self,
) transition: .activityViewControllerPresent(animated: true)
} )
} }
}, },
UIAction( UIAction(
title: L10n.Common.Controls.Status.Actions.shareLinkInPost, title: L10n.Common.Controls.Status.Actions.shareLinkInPost,
image: Asset.ObjectsAndTools.squareAndPencil.image.withRenderingMode(.alwaysTemplate) image: Asset.ObjectsAndTools.squareAndPencil.image.withRenderingMode(.alwaysTemplate)
) { _ in ) { _ in
Task { DispatchQueue.main.async {
await MainActor.run { self.coordinator.present(
self.coordinator.present( scene: .compose(viewModel: ComposeViewModel(
scene: .compose(viewModel: ComposeViewModel( context: self.context,
context: self.context, authContext: self.authContext,
authContext: self.authContext, destination: .topLevel,
destination: .topLevel, initialContent: L10n.Common.Controls.Status.linkViaUser(url.absoluteString, "@" + (statusView.viewModel.authorUsername ?? ""))
initialContent: L10n.Common.Controls.Status.linkViaUser(url.absoluteString, "@" + (statusView.viewModel.authorUsername ?? "")) )),
)), from: self,
from: self, transition: .modal(animated: true)
transition: .modal(animated: true) )
)
}
} }
} }
]) ])