diff --git a/Mac/MainWindow/MainWindowController.swift b/Mac/MainWindow/MainWindowController.swift index 0bef4b254..fe988889e 100644 --- a/Mac/MainWindow/MainWindowController.swift +++ b/Mac/MainWindow/MainWindowController.swift @@ -397,8 +397,9 @@ class MainWindowController : NSWindowController, NSUserInterfaceValidations { } @IBAction func markAllAsReadAndGoToNextUnread(_ sender: Any?) { - markAllAsRead(sender) - nextUnread(sender) + currentTimelineViewController?.markAllAsRead() { + self.nextUnread(sender) + } } @IBAction func markUnreadAndGoToNextUnread(_ sender: Any?) { diff --git a/Mac/MainWindow/Timeline/TimelineViewController.swift b/Mac/MainWindow/Timeline/TimelineViewController.swift index 2e373e6bf..fff7b1324 100644 --- a/Mac/MainWindow/Timeline/TimelineViewController.swift +++ b/Mac/MainWindow/Timeline/TimelineViewController.swift @@ -233,8 +233,8 @@ final class TimelineViewController: NSViewController, UndoableCommandRunner, Unr // MARK: - API - func markAllAsRead() { - guard let undoManager = undoManager, let markReadCommand = MarkStatusCommand(initialArticles: articles, markingRead: true, undoManager: undoManager) else { + func markAllAsRead(completion: (() -> Void)? = nil) { + guard let undoManager = undoManager, let markReadCommand = MarkStatusCommand(initialArticles: articles, markingRead: true, undoManager: undoManager, completion: completion) else { return } runCommand(markReadCommand) diff --git a/Shared/Commands/MarkStatusCommand.swift b/Shared/Commands/MarkStatusCommand.swift index b1e5f4c5c..e6eae4b54 100644 --- a/Shared/Commands/MarkStatusCommand.swift +++ b/Shared/Commands/MarkStatusCommand.swift @@ -41,12 +41,12 @@ final class MarkStatusCommand: UndoableCommand { self.redoActionName = actionName } - convenience init?(initialArticles: [Article], markingRead: Bool, undoManager: UndoManager) { - self.init(initialArticles: initialArticles, statusKey: .read, flag: markingRead, undoManager: undoManager) + convenience init?(initialArticles: [Article], markingRead: Bool, undoManager: UndoManager, completion: (() -> Void)? = nil) { + self.init(initialArticles: initialArticles, statusKey: .read, flag: markingRead, undoManager: undoManager, completion: completion) } - convenience init?(initialArticles: [Article], markingStarred: Bool, undoManager: UndoManager) { - self.init(initialArticles: initialArticles, statusKey: .starred, flag: markingStarred, undoManager: undoManager) + convenience init?(initialArticles: [Article], markingStarred: Bool, undoManager: UndoManager, completion: (() -> Void)? = nil) { + self.init(initialArticles: initialArticles, statusKey: .starred, flag: markingStarred, undoManager: undoManager, completion: completion) } func perform() {