From a8f090656d8177c5f7aa03ea2794ce6c573c14be Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Thu, 30 May 2019 14:44:13 -0500 Subject: [PATCH] Handle when a feed in a folder being copied/moved already is subscribed in target account --- .../Sidebar/SidebarOutlineDataSource.swift | 30 ++++++++++++++----- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/Mac/MainWindow/Sidebar/SidebarOutlineDataSource.swift b/Mac/MainWindow/Sidebar/SidebarOutlineDataSource.swift index 1eff773aa..d81048636 100644 --- a/Mac/MainWindow/Sidebar/SidebarOutlineDataSource.swift +++ b/Mac/MainWindow/Sidebar/SidebarOutlineDataSource.swift @@ -492,14 +492,27 @@ private extension SidebarOutlineDataSource { case .success(let destinationFolder): let group = DispatchGroup() for feed in folder.topLevelFeeds { - group.enter() - destinationAccount.createFeed(url: feed.url, name: feed.editedName, container: destinationFolder) { result in - group.leave() - switch result { - case .success: - break - case .failure(let error): - NSApplication.shared.presentError(error) + if let existingFeed = destinationAccount.existingFeed(withURL: feed.url) { + group.enter() + destinationAccount.addFeed(existingFeed, to: destinationFolder) { result in + group.leave() + switch result { + case .success: + break + case .failure(let error): + NSApplication.shared.presentError(error) + } + } + } else { + group.enter() + destinationAccount.createFeed(url: feed.url, name: feed.editedName, container: destinationFolder) { result in + group.leave() + switch result { + case .success: + break + case .failure(let error): + NSApplication.shared.presentError(error) + } } } } @@ -508,6 +521,7 @@ private extension SidebarOutlineDataSource { } case .failure(let error): NSApplication.shared.presentError(error) + completion() } }