Check if the Micro.blog app exists on disk when app becomes active.

This commit is contained in:
Brent Simmons 2018-01-08 22:10:56 -08:00
parent b83a5694dc
commit 17ce4fc26a
2 changed files with 19 additions and 8 deletions

View File

@ -8,7 +8,7 @@
import Foundation import Foundation
struct SendToMarsEditCommand { final class SendToMarsEditCommand: SendToCommand {
func canSendObject(_ object: Any?) -> Bool { func canSendObject(_ object: Any?) -> Bool {

View File

@ -6,26 +6,37 @@
// Copyright © 2018 Ranchero Software. All rights reserved. // Copyright © 2018 Ranchero Software. All rights reserved.
// //
import Foundation import Cocoa
// Not undoable. // 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 { func canSendObject(_ object: Any?) -> Bool {
if !appExists {
return false
}
return false return false
} }
func sendObject(_ object: Any?) { func sendObject(_ object: Any?) {
} }
}
private extension SendToMicroBlogCommand {
func appExists() {
@objc func appDidBecomeActive(_ note: Notification) {
self.appExists = appExistsOnDisk(bundleID)
} }
} }