From 7264ea996b2ce29a308ef1f91eeca9e9e180eaf8 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Sat, 9 Jan 2021 17:58:51 -0600 Subject: [PATCH] Wait until statuses have finished syncing before allowing the application to quit. Fixes #2718 --- Mac/AppDelegate.swift | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Mac/AppDelegate.swift b/Mac/AppDelegate.swift index b5eb7e17e..88fcb3d0e 100644 --- a/Mac/AppDelegate.swift +++ b/Mac/AppDelegate.swift @@ -61,6 +61,8 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations, } } + var isShutDownSyncDone = false + @IBOutlet var debugMenuItem: NSMenuItem! @IBOutlet var sortByOldestArticleOnTopMenuItem: NSMenuItem! @IBOutlet var sortByNewestArticleOnTopMenuItem: NSMenuItem! @@ -310,6 +312,12 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations, func applicationWillTerminate(_ notification: Notification) { shuttingDown = true saveState() + + AccountManager.shared.syncArticleStatusAll() { + self.isShutDownSyncDone = true + } + + while !isShutDownSyncDone && RunLoop.current.run(mode: .default, before: .distantFuture) { } } // MARK: Notifications