Stub out syncing article state
This commit is contained in:
parent
6d5b3884fc
commit
39a337d096
@ -77,7 +77,9 @@ final class FeedbinAccountDelegate: AccountDelegate {
|
||||
case .success():
|
||||
|
||||
self?.refreshArticles(account) {
|
||||
completion?()
|
||||
self?.refreshArticleStatus(for: account) {
|
||||
completion?()
|
||||
}
|
||||
}
|
||||
|
||||
case .failure(let error):
|
||||
@ -91,6 +93,48 @@ final class FeedbinAccountDelegate: AccountDelegate {
|
||||
|
||||
}
|
||||
|
||||
func refreshArticleStatus(for account: Account, completion: (() -> Void)? = nil) {
|
||||
|
||||
os_log(.debug, log: log, "Refreshing article statuses...")
|
||||
|
||||
let group = DispatchGroup()
|
||||
|
||||
group.enter()
|
||||
caller.retrieveUnreadEntries() { [weak self] result in
|
||||
switch result {
|
||||
case .success(let articleIDs):
|
||||
self?.syncArticleReadState(account: account, articleIDs: articleIDs) {
|
||||
group.leave()
|
||||
}
|
||||
case .failure(let error):
|
||||
guard let self = self else { return }
|
||||
os_log(.info, log: self.log, "Retrieving unread entries failed: %@.", error.localizedDescription)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
group.enter()
|
||||
caller.retrieveStarredEntries() { [weak self] result in
|
||||
switch result {
|
||||
case .success(let articleIDs):
|
||||
self?.syncArticleStarredState(account: account, articleIDs: articleIDs) {
|
||||
group.leave()
|
||||
}
|
||||
case .failure(let error):
|
||||
guard let self = self else { return }
|
||||
os_log(.info, log: self.log, "Retrieving starred entries failed: %@.", error.localizedDescription)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
group.notify(queue: DispatchQueue.main) { [weak self] in
|
||||
guard let self = self else { return }
|
||||
os_log(.debug, log: self.log, "Done refreshing article statuses.")
|
||||
completion?()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func importOPML(for account:Account, opmlFile: URL, completion: @escaping (Result<Void, Error>) -> Void) {
|
||||
|
||||
var fileData: Data?
|
||||
@ -969,4 +1013,30 @@ private extension FeedbinAccountDelegate {
|
||||
|
||||
}
|
||||
|
||||
func syncArticleReadState(account: Account, articleIDs: [Int]?, completion: (() -> Void)) {
|
||||
|
||||
guard let articleIDs = articleIDs, !articleIDs.isEmpty else {
|
||||
completion()
|
||||
return
|
||||
}
|
||||
|
||||
let ids = Set(articleIDs.map { String($0) } )
|
||||
|
||||
completion()
|
||||
|
||||
}
|
||||
|
||||
func syncArticleStarredState(account: Account, articleIDs: [Int]?, completion: (() -> Void)) {
|
||||
|
||||
guard let articleIDs = articleIDs, !articleIDs.isEmpty else {
|
||||
completion()
|
||||
return
|
||||
}
|
||||
|
||||
let ids = Set(articleIDs.map { String($0) } )
|
||||
|
||||
completion()
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user