Browse Source

Show error notification if publishing fails

master
Matt Baer 4 years ago
parent
commit
6ab534d0f3
1 changed files with 13 additions and 7 deletions
  1. +13
    -7
      writeas/ViewController.swift

+ 13
- 7
writeas/ViewController.swift View File

@@ -102,17 +102,23 @@ class ViewController: NSViewController, NSTextViewDelegate, NSUserNotificationCe
task.waitUntilExit()

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 {
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)
}
}


Loading…
Cancel
Save