From cb93c3874f49e799739faebb7f680ec539cd4b28 Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Mon, 31 Jul 2017 19:33:49 -0400 Subject: [PATCH] Disable Publish menu item while publishing --- writeas/AppDelegate.swift | 3 +++ writeas/Base.lproj/Main.storyboard | 1 + writeas/ViewController.swift | 4 ++++ 3 files changed, 8 insertions(+) diff --git a/writeas/AppDelegate.swift b/writeas/AppDelegate.swift index ce06e9a..c983426 100644 --- a/writeas/AppDelegate.swift +++ b/writeas/AppDelegate.swift @@ -7,12 +7,14 @@ // import Cocoa +import Foundation @NSApplicationMain class AppDelegate: NSObject, NSApplicationDelegate { var vc: ViewController? + @IBOutlet weak var filePublishItem: NSMenuItem! @IBOutlet weak var nightModeItem: NSMenuItem! @IBOutlet weak var formatFontSerifItem: NSMenuItem! @IBOutlet weak var formatFontSansItem: NSMenuItem! @@ -85,6 +87,7 @@ class AppDelegate: NSObject, NSApplicationDelegate { } @IBAction func publishDoc(_ sender: Any) { + filePublishItem.isEnabled = false vc?.publish() } diff --git a/writeas/Base.lproj/Main.storyboard b/writeas/Base.lproj/Main.storyboard index a415217..5a6bc09 100644 --- a/writeas/Base.lproj/Main.storyboard +++ b/writeas/Base.lproj/Main.storyboard @@ -368,6 +368,7 @@ DQ + diff --git a/writeas/ViewController.swift b/writeas/ViewController.swift index 1120fad..026e539 100644 --- a/writeas/ViewController.swift +++ b/writeas/ViewController.swift @@ -110,6 +110,10 @@ class ViewController: NSViewController, NSTextViewDelegate, NSUserNotificationCe 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 + } + NSUserNotificationCenter.default.deliver(notification) } }