mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Make the send-to-Micro.blog command work. Need some tweaking, but it mostly does the job.
This commit is contained in:
@@ -13,18 +13,18 @@ import Data
|
||||
|
||||
final class SendToMicroBlogCommand: SendToCommand {
|
||||
|
||||
private let bundleID = "blog.micro.mac"
|
||||
private var appExists = false
|
||||
let title = NSLocalizedString("Send to Micro.blog", comment: "Send to command")
|
||||
|
||||
init() {
|
||||
|
||||
self.appExists = appExistsOnDisk(bundleID)
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(appDidBecomeActive(_:)), name: NSApplication.didBecomeActiveNotification, object: nil)
|
||||
var image: NSImage? {
|
||||
return microBlogApp.icon
|
||||
}
|
||||
|
||||
private let microBlogApp = ApplicationSpecifier(bundleID: "blog.micro.mac")
|
||||
|
||||
func canSendObject(_ object: Any?, selectedText: String?) -> Bool {
|
||||
|
||||
guard appExists, let article = object as? Article, let _ = article.preferredLink else {
|
||||
microBlogApp.update()
|
||||
guard microBlogApp.existsOnDisk, let article = (object as? ArticlePasteboardWriter)?.article, let _ = article.preferredLink else {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -36,7 +36,10 @@ final class SendToMicroBlogCommand: SendToCommand {
|
||||
guard canSendObject(object, selectedText: selectedText) else {
|
||||
return
|
||||
}
|
||||
guard let article = object as? Article else {
|
||||
guard let article = (object as? ArticlePasteboardWriter)?.article else {
|
||||
return
|
||||
}
|
||||
guard microBlogApp.existsOnDisk, microBlogApp.launch() else {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -67,11 +70,6 @@ final class SendToMicroBlogCommand: SendToCommand {
|
||||
|
||||
let _ = try? NSWorkspace.shared.open(url, options: [], configuration: [:])
|
||||
}
|
||||
|
||||
@objc func appDidBecomeActive(_ note: Notification) {
|
||||
|
||||
self.appExists = appExistsOnDisk(bundleID)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user