diff --git a/Commands/SendToMarsEditCommand.swift b/Commands/SendToMarsEditCommand.swift index b48662ac4..ca1e29d81 100644 --- a/Commands/SendToMarsEditCommand.swift +++ b/Commands/SendToMarsEditCommand.swift @@ -8,7 +8,7 @@ import Foundation -struct SendToMarsEditCommand { +final class SendToMarsEditCommand: SendToCommand { func canSendObject(_ object: Any?) -> Bool { diff --git a/Commands/SendToMicroBlogCommand.swift b/Commands/SendToMicroBlogCommand.swift index 1c80fc9a2..8260799dc 100644 --- a/Commands/SendToMicroBlogCommand.swift +++ b/Commands/SendToMicroBlogCommand.swift @@ -6,26 +6,37 @@ // Copyright © 2018 Ranchero Software. All rights reserved. // -import Foundation +import Cocoa // Not undoable. -struct SendToMicroBlogCommand: SendToCommand { +final class SendToMicroBlogCommand: SendToCommand { + + private let bundleID = "blog.micro.mac" + private var appExists = false + + init() { + + self.appExists = appExistsOnDisk(bundleID) + NotificationCenter.default.addObserver(self, selector: #selector(appDidBecomeActive(_:)), name: NSApplication.didBecomeActiveNotification, object: nil) + } func canSendObject(_ object: Any?) -> Bool { + if !appExists { + return false + } return false } func sendObject(_ object: Any?) { } -} -private extension SendToMicroBlogCommand { + @objc func appDidBecomeActive(_ note: Notification) { - func appExists() { - - + self.appExists = appExistsOnDisk(bundleID) } } + +