mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2024-12-25 01:01:21 +01:00
Make sure all the read and starred statuses are recorded before retrieving the missing articles
This commit is contained in:
parent
75fb3fa5fb
commit
100a596d02
@ -186,8 +186,9 @@ final class ReaderAPIAccountDelegate: AccountDelegate {
|
|||||||
caller.retrieveItemIDs(type: .unread) { result in
|
caller.retrieveItemIDs(type: .unread) { result in
|
||||||
switch result {
|
switch result {
|
||||||
case .success(let articleIDs):
|
case .success(let articleIDs):
|
||||||
self.syncArticleReadState(account: account, articleIDs: articleIDs)
|
self.syncArticleReadState(account: account, articleIDs: articleIDs) {
|
||||||
group.leave()
|
group.leave()
|
||||||
|
}
|
||||||
case .failure(let error):
|
case .failure(let error):
|
||||||
os_log(.info, log: self.log, "Retrieving unread entries failed: %@.", error.localizedDescription)
|
os_log(.info, log: self.log, "Retrieving unread entries failed: %@.", error.localizedDescription)
|
||||||
group.leave()
|
group.leave()
|
||||||
@ -199,8 +200,9 @@ final class ReaderAPIAccountDelegate: AccountDelegate {
|
|||||||
caller.retrieveItemIDs(type: .starred) { result in
|
caller.retrieveItemIDs(type: .starred) { result in
|
||||||
switch result {
|
switch result {
|
||||||
case .success(let articleIDs):
|
case .success(let articleIDs):
|
||||||
self.syncArticleStarredState(account: account, articleIDs: articleIDs)
|
self.syncArticleStarredState(account: account, articleIDs: articleIDs) {
|
||||||
group.leave()
|
group.leave()
|
||||||
|
}
|
||||||
case .failure(let error):
|
case .failure(let error):
|
||||||
os_log(.info, log: self.log, "Retrieving starred entries failed: %@.", error.localizedDescription)
|
os_log(.info, log: self.log, "Retrieving starred entries failed: %@.", error.localizedDescription)
|
||||||
group.leave()
|
group.leave()
|
||||||
@ -1001,7 +1003,7 @@ private extension ReaderAPIAccountDelegate {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func syncArticleReadState(account: Account, articleIDs: [String]?) {
|
func syncArticleReadState(account: Account, articleIDs: [String]?, completion: @escaping (() -> Void)) {
|
||||||
guard let articleIDs = articleIDs else {
|
guard let articleIDs = articleIDs else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -1016,13 +1018,25 @@ private extension ReaderAPIAccountDelegate {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let group = DispatchGroup()
|
||||||
|
|
||||||
// Mark articles as unread
|
// Mark articles as unread
|
||||||
let deltaUnreadArticleIDs = updatableReaderUnreadArticleIDs.subtracting(currentUnreadArticleIDs)
|
let deltaUnreadArticleIDs = updatableReaderUnreadArticleIDs.subtracting(currentUnreadArticleIDs)
|
||||||
account.markAsUnread(deltaUnreadArticleIDs)
|
group.enter()
|
||||||
|
account.markAsUnread(deltaUnreadArticleIDs) { _ in
|
||||||
|
group.leave()
|
||||||
|
}
|
||||||
|
|
||||||
// Mark articles as read
|
// Mark articles as read
|
||||||
let deltaReadArticleIDs = currentUnreadArticleIDs.subtracting(updatableReaderUnreadArticleIDs)
|
let deltaReadArticleIDs = currentUnreadArticleIDs.subtracting(updatableReaderUnreadArticleIDs)
|
||||||
account.markAsRead(deltaReadArticleIDs)
|
group.enter()
|
||||||
|
account.markAsRead(deltaReadArticleIDs) { _ in
|
||||||
|
group.leave()
|
||||||
|
}
|
||||||
|
|
||||||
|
group.notify(queue: DispatchQueue.main) {
|
||||||
|
completion()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1037,7 +1051,7 @@ private extension ReaderAPIAccountDelegate {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func syncArticleStarredState(account: Account, articleIDs: [String]?) {
|
func syncArticleStarredState(account: Account, articleIDs: [String]?, completion: @escaping (() -> Void)) {
|
||||||
guard let articleIDs = articleIDs else {
|
guard let articleIDs = articleIDs else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -1052,13 +1066,25 @@ private extension ReaderAPIAccountDelegate {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let group = DispatchGroup()
|
||||||
|
|
||||||
// Mark articles as starred
|
// Mark articles as starred
|
||||||
let deltaStarredArticleIDs = updatableReaderUnreadArticleIDs.subtracting(currentStarredArticleIDs)
|
let deltaStarredArticleIDs = updatableReaderUnreadArticleIDs.subtracting(currentStarredArticleIDs)
|
||||||
account.markAsStarred(deltaStarredArticleIDs)
|
group.enter()
|
||||||
|
account.markAsStarred(deltaStarredArticleIDs) { _ in
|
||||||
|
group.leave()
|
||||||
|
}
|
||||||
|
|
||||||
// Mark articles as unstarred
|
// Mark articles as unstarred
|
||||||
let deltaUnstarredArticleIDs = currentStarredArticleIDs.subtracting(updatableReaderUnreadArticleIDs)
|
let deltaUnstarredArticleIDs = currentStarredArticleIDs.subtracting(updatableReaderUnreadArticleIDs)
|
||||||
account.markAsUnstarred(deltaUnstarredArticleIDs)
|
group.enter()
|
||||||
|
account.markAsUnstarred(deltaUnstarredArticleIDs) { _ in
|
||||||
|
group.leave()
|
||||||
|
}
|
||||||
|
|
||||||
|
group.notify(queue: DispatchQueue.main) {
|
||||||
|
completion()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user