mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2025-01-23 15:50:26 +01:00
Delegate article marking functionality to the account delegate
This commit is contained in:
parent
7de24e1d53
commit
30273795a8
@ -305,18 +305,7 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
|
||||
}
|
||||
|
||||
public func markArticles(_ articles: Set<Article>, statusKey: ArticleStatus.Key, flag: Bool) -> Set<Article>? {
|
||||
|
||||
// Returns set of Articles whose statuses did change.
|
||||
|
||||
guard let updatedStatuses = database.mark(articles, statusKey: statusKey, flag: flag) else {
|
||||
return nil
|
||||
}
|
||||
|
||||
let updatedArticleIDs = updatedStatuses.articleIDs()
|
||||
let updatedArticles = Set(articles.filter{ updatedArticleIDs.contains($0.articleID) })
|
||||
|
||||
noteStatusesForArticlesDidChange(updatedArticles)
|
||||
return updatedArticles
|
||||
return delegate.markArticles(for: self, articles: articles, statusKey: statusKey, flag: flag)
|
||||
}
|
||||
|
||||
@discardableResult
|
||||
@ -617,6 +606,22 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
|
||||
|
||||
}
|
||||
|
||||
func update(_ articles: Set<Article>, statusKey: ArticleStatus.Key, flag: Bool) -> Set<Article>? {
|
||||
|
||||
// Returns set of Articles whose statuses did change.
|
||||
|
||||
guard let updatedStatuses = database.mark(articles, statusKey: statusKey, flag: flag) else {
|
||||
return nil
|
||||
}
|
||||
|
||||
let updatedArticleIDs = updatedStatuses.articleIDs()
|
||||
let updatedArticles = Set(articles.filter{ updatedArticleIDs.contains($0.articleID) })
|
||||
|
||||
noteStatusesForArticlesDidChange(updatedArticles)
|
||||
return updatedArticles
|
||||
|
||||
}
|
||||
|
||||
func ensureStatuses(_ articleIDs: Set<String>, _ statusKey: ArticleStatus.Key, _ flag: Bool) {
|
||||
database.ensureStatuses(articleIDs, statusKey, flag)
|
||||
}
|
||||
|
@ -7,6 +7,7 @@
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import Articles
|
||||
import RSWeb
|
||||
|
||||
protocol AccountDelegate {
|
||||
@ -35,6 +36,8 @@ protocol AccountDelegate {
|
||||
func restoreFeed(for account: Account, feed: Feed, folder: Folder?, completion: @escaping (Result<Void, Error>) -> Void)
|
||||
func restoreFolder(for account: Account, folder: Folder, completion: @escaping (Result<Void, Error>) -> Void)
|
||||
|
||||
func markArticles(for account: Account, articles: Set<Article>, statusKey: ArticleStatus.Key, flag: Bool) -> Set<Article>?
|
||||
|
||||
// Called at the end of account’s init method.
|
||||
func accountDidInitialize(_ account: Account)
|
||||
|
||||
|
@ -12,6 +12,7 @@ import AppKit
|
||||
import UIKit
|
||||
import RSCore
|
||||
#endif
|
||||
import Articles
|
||||
import RSCore
|
||||
import RSParser
|
||||
import RSWeb
|
||||
@ -400,6 +401,10 @@ final class FeedbinAccountDelegate: AccountDelegate {
|
||||
|
||||
}
|
||||
|
||||
func markArticles(for account: Account, articles: Set<Article>, statusKey: ArticleStatus.Key, flag: Bool) -> Set<Article>? {
|
||||
return account.update(articles, statusKey: statusKey, flag: flag)
|
||||
}
|
||||
|
||||
func accountDidInitialize(_ account: Account) {
|
||||
credentials = try? account.retrieveBasicCredentials()
|
||||
accountMetadata = account.metadata
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
import Foundation
|
||||
import RSParser
|
||||
import Articles
|
||||
import RSWeb
|
||||
|
||||
public enum LocalAccountDelegateError: String, Error {
|
||||
@ -160,6 +161,10 @@ final class LocalAccountDelegate: AccountDelegate {
|
||||
completion(.success(()))
|
||||
}
|
||||
|
||||
func markArticles(for account: Account, articles: Set<Article>, statusKey: ArticleStatus.Key, flag: Bool) -> Set<Article>? {
|
||||
return account.update(articles, statusKey: statusKey, flag: flag)
|
||||
}
|
||||
|
||||
func accountDidInitialize(_ account: Account) {
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user