Fetch starred articles for the Starred smart feed.
This commit is contained in:
parent
668f614aad
commit
a13d21395e
|
@ -24,8 +24,11 @@ struct StarredFeedDelegate: SmartFeedDelegate {
|
|||
|
||||
func fetchArticles() -> Set<Article> {
|
||||
|
||||
// TODO
|
||||
return Set<Article>()
|
||||
var articles = Set<Article>()
|
||||
for account in AccountManager.shared.accounts {
|
||||
articles.formUnion(account.fetchStarredArticles())
|
||||
}
|
||||
return articles
|
||||
}
|
||||
|
||||
func fetchUnreadArticles() -> Set<Article> {
|
||||
|
|
|
@ -364,6 +364,11 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
|
|||
return database.fetchTodayArticles(for: flattenedFeeds())
|
||||
}
|
||||
|
||||
public func fetchStarredArticles() -> Set<Article> {
|
||||
|
||||
return database.fetchStarredArticles(for: flattenedFeeds())
|
||||
}
|
||||
|
||||
private func validateUnreadCount(_ feed: Feed, _ articles: Set<Article>) {
|
||||
|
||||
// articles must contain all the unread articles for the feed.
|
||||
|
|
|
@ -77,6 +77,11 @@ final class ArticlesTable: DatabaseTable {
|
|||
return fetchTodayArticles(feeds.feedIDs())
|
||||
}
|
||||
|
||||
public func fetchStarredArticles(for feeds: Set<Feed>) -> Set<Article> {
|
||||
|
||||
return fetchStarredArticles(feeds.feedIDs())
|
||||
}
|
||||
|
||||
// MARK: Updating
|
||||
|
||||
func update(_ feed: Feed, _ parsedFeed: ParsedFeed, _ completion: @escaping UpdateArticlesWithFeedCompletionBlock) {
|
||||
|
@ -405,6 +410,28 @@ private extension ArticlesTable {
|
|||
return articles
|
||||
}
|
||||
|
||||
func fetchStarredArticles(_ feedIDs: Set<String>) -> Set<Article> {
|
||||
|
||||
if feedIDs.isEmpty {
|
||||
return Set<Article>()
|
||||
}
|
||||
|
||||
var articles = Set<Article>()
|
||||
|
||||
queue.fetchSync { (database) in
|
||||
|
||||
// select * from articles natural join statuses where feedID in ('http://ranchero.com/xml/rss.xml') and starred = 1 and userDeleted = 0;
|
||||
|
||||
let parameters = feedIDs.map { $0 as AnyObject }
|
||||
let placeholders = NSString.rs_SQLValueList(withPlaceholders: UInt(feedIDs.count))!
|
||||
let whereClause = "feedID in \(placeholders) and starred = 1 and userDeleted = 0"
|
||||
articles = self.fetchArticlesWithWhereClause(database, whereClause: whereClause, parameters: parameters, withLimits: false)
|
||||
}
|
||||
|
||||
return articles
|
||||
}
|
||||
|
||||
|
||||
func articlesWithSQL(_ sql: String, _ parameters: [AnyObject], _ database: FMDatabase) -> Set<Article> {
|
||||
|
||||
guard let resultSet = database.executeQuery(sql, withArgumentsIn: parameters) else {
|
||||
|
|
|
@ -62,6 +62,11 @@ public final class Database {
|
|||
return articlesTable.fetchTodayArticles(for: feeds)
|
||||
}
|
||||
|
||||
public func fetchStarredArticles(for feeds: Set<Feed>) -> Set<Article> {
|
||||
|
||||
return articlesTable.fetchStarredArticles(for: feeds)
|
||||
}
|
||||
|
||||
// MARK: - Unread Counts
|
||||
|
||||
public func fetchUnreadCounts(for feeds: Set<Feed>, _ completion: @escaping UnreadCountCompletionBlock) {
|
||||
|
|
Loading…
Reference in New Issue