Make sure mark as read completes before searching for the next unread. Fixes #2952

This commit is contained in:
Maurice Parker 2021-04-15 14:29:49 -05:00
parent 92fd016b7a
commit 3955151daf
4 changed files with 11 additions and 10 deletions

View File

@ -843,7 +843,7 @@ private extension AppDelegate {
os_log(.debug, "No article found from search using %@", articleID)
return
}
account!.markArticles(article!, statusKey: .read, flag: true)
account!.markArticles(article!, statusKey: .read, flag: true) { _ in }
}
func handleMarkAsStarred(userInfo: [AnyHashable: Any]) {
@ -862,6 +862,6 @@ private extension AppDelegate {
os_log(.debug, "No article found from search using %@", articleID)
return
}
account!.markArticles(article!, statusKey: .starred, flag: true)
account!.markArticles(article!, statusKey: .starred, flag: true) { _ in }
}
}

View File

@ -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?) {

View File

@ -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)

View File

@ -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() {