Deal with impact of async changes to UserApp.

This commit is contained in:
Brent Simmons
2025-04-25 09:16:00 -07:00
parent 8742114015
commit db3cbaa8a3
2 changed files with 28 additions and 19 deletions

View File

@@ -29,11 +29,17 @@ final class SendToMarsEditCommand: SendToCommand {
guard let article = (object as? ArticlePasteboardWriter)?.article else {
return
}
guard let app = appToUse(), app.launchIfNeeded(), app.bringToFront() else {
guard let app = appToUse() else {
return
}
send(article, to: app)
Task {
guard await app.launchIfNeeded(), app.bringToFront() else {
return
}
send(article, to: app)
}
}
}

View File

@@ -37,24 +37,27 @@ final class SendToMicroBlogCommand: SendToCommand {
guard let article = (object as? ArticlePasteboardWriter)?.article else {
return
}
guard microBlogApp.launchIfNeeded(), microBlogApp.bringToFront() else {
return
Task {
guard await microBlogApp.launchIfNeeded(), microBlogApp.bringToFront() else {
return
}
// TODO: get text from contentHTML or contentText if no title and no selectedText.
// TODO: consider selectedText.
let s = article.attributionString + article.linkString
let urlQueryDictionary = ["text": s]
guard let urlQueryString = urlQueryDictionary.urlQueryString else {
return
}
guard let url = URL(string: "microblog://post?" + urlQueryString) else {
return
}
NSWorkspace.shared.open(url)
}
// TODO: get text from contentHTML or contentText if no title and no selectedText.
// TODO: consider selectedText.
let s = article.attributionString + article.linkString
let urlQueryDictionary = ["text": s]
guard let urlQueryString = urlQueryDictionary.urlQueryString else {
return
}
guard let url = URL(string: "microblog://post?" + urlQueryString) else {
return
}
NSWorkspace.shared.open(url)
}
}