From 7ddcb2fc8e9937b647016412f81b3ede63f4ca9d Mon Sep 17 00:00:00 2001 From: Kiel Gillard Date: Wed, 18 Dec 2019 09:41:45 +1100 Subject: [PATCH] Add optional completions to avoid race conditions involving these marked statuses. --- Frameworks/Account/Account.swift | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Frameworks/Account/Account.swift b/Frameworks/Account/Account.swift index 63f19149d..d3b38278b 100644 --- a/Frameworks/Account/Account.swift +++ b/Frameworks/Account/Account.swift @@ -808,23 +808,23 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container, } /// Mark articleIDs as read. Will create statuses in the database and in memory as needed. Sends a .StatusesDidChange notification. - func markAsRead(_ articleIDs: Set) { - mark(articleIDs: articleIDs, statusKey: .read, flag: true) + func markAsRead(_ articleIDs: Set, completion: DatabaseCompletionBlock? = nil) { + mark(articleIDs: articleIDs, statusKey: .read, flag: true, completion: completion) } /// Mark articleIDs as unread. Will create statuses in the database and in memory as needed. Sends a .StatusesDidChange notification. - func markAsUnread(_ articleIDs: Set) { - mark(articleIDs: articleIDs, statusKey: .read, flag: false) + func markAsUnread(_ articleIDs: Set, completion: DatabaseCompletionBlock? = nil) { + mark(articleIDs: articleIDs, statusKey: .read, flag: false, completion: completion) } /// Mark articleIDs as starred. Will create statuses in the database and in memory as needed. Sends a .StatusesDidChange notification. - func markAsStarred(_ articleIDs: Set) { - mark(articleIDs: articleIDs, statusKey: .starred, flag: true) + func markAsStarred(_ articleIDs: Set, completion: DatabaseCompletionBlock? = nil) { + mark(articleIDs: articleIDs, statusKey: .starred, flag: true, completion: completion) } /// Mark articleIDs as unstarred. Will create statuses in the database and in memory as needed. Sends a .StatusesDidChange notification. - func markAsUnstarred(_ articleIDs: Set) { - mark(articleIDs: articleIDs, statusKey: .starred, flag: false) + func markAsUnstarred(_ articleIDs: Set, completion: DatabaseCompletionBlock? = nil) { + mark(articleIDs: articleIDs, statusKey: .starred, flag: false, completion: completion) } /// Empty caches that can reasonably be emptied. Call when the app goes in the background, for instance.