From 9865bd8e518c96c981b09f143876ca65cef292b8 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Sat, 25 Nov 2017 13:11:19 -0800 Subject: [PATCH] =?UTF-8?q?Fix=20a=20crash=20on=20startup=20=E2=80=94?= =?UTF-8?q?=C2=A0detect=20when=20there=20are=20no=20feeds=20and=20don?= =?UTF-8?q?=E2=80=99t=20hit=20database.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Frameworks/Database/ArticlesTable.swift | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Frameworks/Database/ArticlesTable.swift b/Frameworks/Database/ArticlesTable.swift index 7d6bd1af1..89708a4a7 100644 --- a/Frameworks/Database/ArticlesTable.swift +++ b/Frameworks/Database/ArticlesTable.swift @@ -127,6 +127,11 @@ final class ArticlesTable: DatabaseTable { func fetchUnreadCounts(_ feeds: Set, _ 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, _ callback: @escaping (Int) -> Void) { + if feeds.isEmpty { + callback(0) + return + } + let feedIDs = feeds.feedIDs() queue.fetch { (database) in