Fix a crash on startup — detect when there are no feeds and don’t hit database.

This commit is contained in:
Brent Simmons 2017-11-25 13:11:19 -08:00
parent 97079108be
commit 9865bd8e51

View File

@ -127,6 +127,11 @@ final class ArticlesTable: DatabaseTable {
func fetchUnreadCounts(_ feeds: Set<Feed>, _ completion: @escaping UnreadCountCompletionBlock) {
if feeds.isEmpty {
completion(UnreadCountDictionary())
return
}
let feedIDs = feeds.feedIDs()
var unreadCountDictionary = UnreadCountDictionary()
@ -146,6 +151,11 @@ final class ArticlesTable: DatabaseTable {
// Get unread count for today, for instance.
if feeds.isEmpty {
callback(0)
return
}
let feedIDs = feeds.feedIDs()
queue.fetch { (database) in
@ -166,6 +176,11 @@ final class ArticlesTable: DatabaseTable {
func fetchStarredAndUnreadCount(_ feeds: Set<Feed>, _ callback: @escaping (Int) -> Void) {
if feeds.isEmpty {
callback(0)
return
}
let feedIDs = feeds.feedIDs()
queue.fetch { (database) in