@@ -15,19 +15,11 @@ import EmitterKit
1515@NSApplicationMain
1616class AppDelegate : NSObject , NSApplicationDelegate , SUUpdaterDelegate {
1717 var updater = SUUpdater ( for: Bundle . main) !
18- var updateFound = Event < Void > ( )
19- var updateNotFound = Event < Void > ( )
20- var updateCanceled = Event < Void > ( )
21-
18+ var updateProcessed = Event < Void > ( )
19+ var willBeDownloadingUpdate = false
2220 func applicationDidFinishLaunching( _ aNotification: Notification ) {
2321 updater. delegate = self
24- updateFound. once { _ in
25- self . updateCanceled. once { _ in
26- Application . start ( )
27- }
28- }
29-
30- updateNotFound. once { _ in
22+ updateProcessed. once { _ in
3123 Application . start ( )
3224 }
3325 updater. checkForUpdatesInBackground ( )
@@ -51,29 +43,40 @@ class AppDelegate: NSObject, NSApplicationDelegate, SUUpdaterDelegate {
5143 }
5244
5345 func updaterDidNotFindUpdate( _ updater: SUUpdater ) {
54- updateNotFound. emit ( )
55- }
56-
57- func updater( _ updater: SUUpdater , didFindValidUpdate item: SUAppcastItem ) {
58- updateFound. emit ( )
46+ updateProcessed. emit ( )
5947 }
6048
6149 func updater( _ updater: SUUpdater , userDidSkipThisVersion item: SUAppcastItem ) {
62- updateCanceled . emit ( )
50+ updateProcessed . emit ( )
6351 }
6452
6553 func updater( _ updater: SUUpdater , didCancelInstallUpdateOnQuit item: SUAppcastItem ) {
66- updateCanceled. emit ( )
54+ updateProcessed. emit ( )
55+ }
56+
57+ func updater( _ updater: SUUpdater , willDownloadUpdate item: SUAppcastItem , with request: NSMutableURLRequest ) {
58+ willBeDownloadingUpdate = true
6759 }
6860
6961 func updater( _ updater: SUUpdater , didDismissUpdateAlertPermanently permanently: Bool , for item: SUAppcastItem ) {
70- // updateCanceled.emit()
62+ Utilities . delay ( 500 , completion: {
63+ if !self . willBeDownloadingUpdate {
64+ self . updateProcessed. emit ( )
65+ }
66+ } )
7167 }
7268
7369 func userDidCancelDownload( _ updater: SUUpdater ) {
74- updateCanceled. emit ( )
70+ updateProcessed. emit ( )
71+ }
72+
73+ func updater( _ updater: SUUpdater , didAbortWithError error: Error ) {
74+ updateProcessed. emit ( )
75+ }
76+
77+ func updater( _ updater: SUUpdater , failedToDownloadUpdate item: SUAppcastItem , error: Error ) {
78+ updateProcessed. emit ( )
7579 }
76-
7780}
7881
7982
0 commit comments