2019-02-25 04:22:16 +01:00
|
|
|
//
|
|
|
|
// SearchFeedDelegate.swift
|
|
|
|
// NetNewsWire
|
|
|
|
//
|
|
|
|
// Created by Brent Simmons on 2/24/19.
|
|
|
|
// Copyright © 2019 Ranchero Software. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import Foundation
|
|
|
|
import Account
|
|
|
|
import Articles
|
|
|
|
|
|
|
|
struct SearchFeedDelegate: SmartFeedDelegate {
|
|
|
|
|
|
|
|
var nameForDisplay: String {
|
|
|
|
return nameForDisplayPrefix + searchString
|
|
|
|
}
|
|
|
|
|
|
|
|
let nameForDisplayPrefix = NSLocalizedString("Search: ", comment: "Search smart feed title prefix")
|
|
|
|
let searchString: String
|
|
|
|
|
|
|
|
init(searchString: String) {
|
|
|
|
self.searchString = searchString
|
|
|
|
}
|
|
|
|
|
|
|
|
func fetchUnreadCount(for: Account, callback: @escaping (Int) -> Void) {
|
|
|
|
// TODO: after 5.0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// MARK: - ArticleFetcher
|
|
|
|
|
|
|
|
extension SearchFeedDelegate: ArticleFetcher {
|
|
|
|
|
|
|
|
func fetchArticles() -> Set<Article> {
|
|
|
|
var articles = Set<Article>()
|
2019-05-02 13:01:30 +02:00
|
|
|
for account in AccountManager.shared.activeAccounts {
|
2019-02-25 04:22:16 +01:00
|
|
|
articles.formUnion(account.fetchArticlesMatching(searchString))
|
|
|
|
}
|
|
|
|
return articles
|
|
|
|
}
|
|
|
|
|
|
|
|
func fetchUnreadArticles() -> Set<Article> {
|
|
|
|
return fetchArticles().unreadArticles()
|
|
|
|
}
|
|
|
|
}
|