NetNewsWire/Shared/SmartFeeds/SmartFeedDelegate.swift

37 lines
931 B
Swift
Raw Normal View History

//
// SmartFeedDelegate.swift
// NetNewsWire
//
// Created by Brent Simmons on 6/25/19.
// Copyright © 2019 Ranchero Software. All rights reserved.
//
import Foundation
import Account
import Articles
import RSCore
2019-11-15 13:19:14 +01:00
protocol SmartFeedDelegate: FeedIdentifiable, DisplayNameProvider, ArticleFetcher, SmallIconProvider {
var fetchType: FetchType { get }
2019-12-15 02:01:34 +01:00
func fetchUnreadCount(for: Account, completion: @escaping (Int) -> Void)
}
extension SmartFeedDelegate {
func fetchArticles() -> Set<Article> {
return AccountManager.shared.fetchArticles(fetchType)
}
2019-12-15 02:01:34 +01:00
func fetchArticlesAsync(_ completion: @escaping ArticleSetBlock) {
AccountManager.shared.fetchArticlesAsync(fetchType, completion)
}
func fetchUnreadArticles() -> Set<Article> {
return fetchArticles().unreadArticles()
}
2019-12-15 02:01:34 +01:00
func fetchUnreadArticlesAsync(_ completion: @escaping ArticleSetBlock) {
fetchArticlesAsync{ completion($0.unreadArticles()) }
}
}