Fix a crash on startup — detect when there are no feeds and don’t hit database.
This commit is contained in:
parent
97079108be
commit
9865bd8e51
|
@ -127,6 +127,11 @@ final class ArticlesTable: DatabaseTable {
|
||||||
|
|
||||||
func fetchUnreadCounts(_ feeds: Set<Feed>, _ completion: @escaping UnreadCountCompletionBlock) {
|
func fetchUnreadCounts(_ feeds: Set<Feed>, _ completion: @escaping UnreadCountCompletionBlock) {
|
||||||
|
|
||||||
|
if feeds.isEmpty {
|
||||||
|
completion(UnreadCountDictionary())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
let feedIDs = feeds.feedIDs()
|
let feedIDs = feeds.feedIDs()
|
||||||
var unreadCountDictionary = UnreadCountDictionary()
|
var unreadCountDictionary = UnreadCountDictionary()
|
||||||
|
|
||||||
|
@ -146,6 +151,11 @@ final class ArticlesTable: DatabaseTable {
|
||||||
|
|
||||||
// Get unread count for today, for instance.
|
// Get unread count for today, for instance.
|
||||||
|
|
||||||
|
if feeds.isEmpty {
|
||||||
|
callback(0)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
let feedIDs = feeds.feedIDs()
|
let feedIDs = feeds.feedIDs()
|
||||||
queue.fetch { (database) in
|
queue.fetch { (database) in
|
||||||
|
|
||||||
|
@ -166,6 +176,11 @@ final class ArticlesTable: DatabaseTable {
|
||||||
|
|
||||||
func fetchStarredAndUnreadCount(_ feeds: Set<Feed>, _ callback: @escaping (Int) -> Void) {
|
func fetchStarredAndUnreadCount(_ feeds: Set<Feed>, _ callback: @escaping (Int) -> Void) {
|
||||||
|
|
||||||
|
if feeds.isEmpty {
|
||||||
|
callback(0)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
let feedIDs = feeds.feedIDs()
|
let feedIDs = feeds.feedIDs()
|
||||||
queue.fetch { (database) in
|
queue.fetch { (database) in
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue