From f2052f110fb41f68d64f3211a76744dbc0cc9765 Mon Sep 17 00:00:00 2001
From: Brent Simmons <brent@ranchero.com>
Date: Mon, 16 Dec 2019 14:59:15 -0800
Subject: [PATCH] Make updateUnreadCounts compatible with database changes.

---
 Frameworks/Account/Account.swift | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/Frameworks/Account/Account.swift b/Frameworks/Account/Account.swift
index 26ce6f721..14352721e 100644
--- a/Frameworks/Account/Account.swift
+++ b/Frameworks/Account/Account.swift
@@ -601,17 +601,21 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
 		structureDidChange()
 	}
 	
-	public func updateUnreadCounts(for webFeeds: Set<WebFeed>, completion: (() -> Void)? = nil) {
+	public func updateUnreadCounts(for webFeeds: Set<WebFeed>, completion: VoidCompletionBlock? = nil) {
 		if webFeeds.isEmpty {
+			completion?()
 			return
 		}
 		
-		database.fetchUnreadCounts(for: webFeeds.webFeedIDs()) { (unreadCountDictionary) in
-			for webFeed in webFeeds {
-				if let unreadCount = unreadCountDictionary[webFeed.webFeedID] {
-					webFeed.unreadCount = unreadCount
+		database.fetchUnreadCounts(for: webFeeds.webFeedIDs()) { unreadCountDictionaryResult in
+			if let unreadCountDictionary = try? unreadCountDictionaryResult.get() {
+				for webFeed in webFeeds {
+					if let unreadCount = unreadCountDictionary[webFeed.webFeedID] {
+						webFeed.unreadCount = unreadCount
+					}
 				}
 			}
+
 			completion?()
 		}
 	}