From afd9a47abd34f5c7712799585024e524d9acb4a1 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Mon, 22 Feb 2021 17:50:30 -0600 Subject: [PATCH] Change so that we only show one error dialog when folder moves/copies can't find one or more feeds. --- .../Sidebar/SidebarOutlineDataSource.swift | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/Mac/MainWindow/Sidebar/SidebarOutlineDataSource.swift b/Mac/MainWindow/Sidebar/SidebarOutlineDataSource.swift index f403d8b25..384b7ba49 100644 --- a/Mac/MainWindow/Sidebar/SidebarOutlineDataSource.swift +++ b/Mac/MainWindow/Sidebar/SidebarOutlineDataSource.swift @@ -12,6 +12,18 @@ import Articles import RSCore import Account +public enum SidebarOutlineDataSourceError: LocalizedError { + case createErrorNotFound([String]) + + public var errorDescription: String? { + switch self { + case .createErrorNotFound(let feedNames): + let message = NSLocalizedString("The following feeds could not be added because they could not be found:\n", comment: "Not found") + return "\(message)\(feedNames.joined(separator: ", "))" + } + } +} + @objc final class SidebarOutlineDataSource: NSObject, NSOutlineViewDataSource { let treeController: TreeController @@ -507,6 +519,7 @@ private extension SidebarOutlineDataSource { switch result { case .success(let destinationFolder): let group = DispatchGroup() + var notFoundFeedNames = [String]() for feed in folder.topLevelWebFeeds { if let existingFeed = destinationAccount.existingWebFeed(withURL: feed.url) { group.enter() @@ -527,13 +540,20 @@ private extension SidebarOutlineDataSource { case .success: break case .failure(let error): - NSApplication.shared.presentError(error) + if let accountError = error as? AccountError, case .createErrorNotFound = accountError { + notFoundFeedNames.append(feed.nameForDisplay) + } else { + NSApplication.shared.presentError(error) + } } } } } group.notify(queue: DispatchQueue.main) { completion() + if !notFoundFeedNames.isEmpty { + NSApplication.shared.presentError(SidebarOutlineDataSourceError.createErrorNotFound(notFoundFeedNames)) + } } case .failure(let error): NSApplication.shared.presentError(error)