Show error notification if publishing fails

This commit is contained in:
Matt Baer 2017-08-02 20:12:27 -04:00
parent 35133ae7c4
commit 6ab534d0f3

View File

@ -102,17 +102,23 @@ class ViewController: NSViewController, NSTextViewDelegate, NSUserNotificationCe
task.waitUntilExit() task.waitUntilExit()
DispatchQueue.main.async { DispatchQueue.main.async {
var notification = NSUserNotification()
// All these values are optional
notification.title = "Published!"
notification.informativeText = "The link is copied — press ⌘+V to share it."
notification.soundName = NSUserNotificationDefaultSoundName
if let ad = NSApplication.shared().delegate as? AppDelegate { if let ad = NSApplication.shared().delegate as? AppDelegate {
ad.filePublishItem.isEnabled = true ad.filePublishItem.isEnabled = true
} }
var notification = NSUserNotification()
if task.terminationStatus == 0 {
// Successfully published
notification.title = "Published!"
notification.informativeText = "The link is copied — press ⌘+V to share it."
} else {
// Something went wrong
notification.title = "Unable to publish."
notification.informativeText = "There was a problem publishing. Please check your internet and try again."
}
notification.soundName = NSUserNotificationDefaultSoundName
NSUserNotificationCenter.default.deliver(notification) NSUserNotificationCenter.default.deliver(notification)
} }
} }