diff --git a/Frameworks/Account/Account.swift b/Frameworks/Account/Account.swift index 3d60bda46..1014d0d8f 100644 --- a/Frameworks/Account/Account.swift +++ b/Frameworks/Account/Account.swift @@ -396,9 +396,9 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container, } - public func deleteFeed(_ feed: Feed, completion: @escaping (Result) -> Void) { + public func deleteFeed(_ feed: Feed, from container: Container?, completion: @escaping (Result) -> Void) { feedMetadata[feed.url] = nil - delegate.deleteFeed(for: self, with: feed, completion: completion) + delegate.deleteFeed(for: self, with: feed, from: container, completion: completion) } public func renameFeed(_ feed: Feed, to name: String, completion: @escaping (Result) -> Void) { diff --git a/Frameworks/Account/AccountDelegate.swift b/Frameworks/Account/AccountDelegate.swift index cfb685f64..0d92a4f77 100644 --- a/Frameworks/Account/AccountDelegate.swift +++ b/Frameworks/Account/AccountDelegate.swift @@ -34,7 +34,7 @@ protocol AccountDelegate { func createFeed(for account: Account, url: String, name: String?, container: Container, completion: @escaping (Result) -> Void) func renameFeed(for account: Account, with feed: Feed, to name: String, completion: @escaping (Result) -> Void) - func deleteFeed(for account: Account, with feed: Feed, completion: @escaping (Result) -> Void) + func deleteFeed(for account: Account, with feed: Feed, from container: Container?, completion: @escaping (Result) -> Void) func addFeed(for account: Account, to container: Container, with: Feed, completion: @escaping (Result) -> Void) func removeFeed(for account: Account, from container: Container, with: Feed, completion: @escaping (Result) -> Void) diff --git a/Frameworks/Account/Feedbin/FeedbinAccountDelegate.swift b/Frameworks/Account/Feedbin/FeedbinAccountDelegate.swift index 798abeee3..8866ff7bf 100644 --- a/Frameworks/Account/Feedbin/FeedbinAccountDelegate.swift +++ b/Frameworks/Account/Feedbin/FeedbinAccountDelegate.swift @@ -340,7 +340,7 @@ final class FeedbinAccountDelegate: AccountDelegate { } - func deleteFeed(for account: Account, with feed: Feed, completion: @escaping (Result) -> Void) { + func deleteFeed(for account: Account, with feed: Feed, from container: Container?, completion: @escaping (Result) -> Void) { // This error should never happen guard let subscriptionID = feed.subscriptionID else { diff --git a/Frameworks/Account/LocalAccount/LocalAccountDelegate.swift b/Frameworks/Account/LocalAccount/LocalAccountDelegate.swift index 34f1c86aa..2cbfe6d67 100644 --- a/Frameworks/Account/LocalAccount/LocalAccountDelegate.swift +++ b/Frameworks/Account/LocalAccount/LocalAccountDelegate.swift @@ -122,8 +122,7 @@ final class LocalAccountDelegate: AccountDelegate { completion(.success(())) } - func deleteFeed(for account: Account, from container: Container, feed: Feed, completion: @escaping (Result) -> Void) { - + func deleteFeed(for account: Account, with feed: Feed, from container: Container?, completion: @escaping (Result) -> Void) { if let account = container as? Account { account.removeFeed(feed) } @@ -131,17 +130,6 @@ final class LocalAccountDelegate: AccountDelegate { folder.removeFeed(feed) } completion(.success(())) - - } - - func deleteFeed(for account: Account, with feed: Feed, completion: @escaping (Result) -> Void) { - account.removeFeed(feed) - if let folders = account.folders { - for folder in folders { - folder.removeFeed(feed) - } - } - completion(.success(())) } func addFeed(for account: Account, to container: Container, with feed: Feed, completion: @escaping (Result) -> Void) { diff --git a/Mac/MainWindow/Sidebar/SidebarOutlineDataSource.swift b/Mac/MainWindow/Sidebar/SidebarOutlineDataSource.swift index 94a805071..214f8bd7d 100644 --- a/Mac/MainWindow/Sidebar/SidebarOutlineDataSource.swift +++ b/Mac/MainWindow/Sidebar/SidebarOutlineDataSource.swift @@ -359,6 +359,7 @@ private extension SidebarOutlineDataSource { func moveBetweenAccounts(node: Node, to parentNode: Node) { guard let feed = node.representedObject as? Feed, let sourceAccount = nodeAccount(node), + let sourceContainer = node.parent?.representedObject as? Container, let destinationAccount = nodeAccount(parentNode), let destinationContainer = parentNode.representedObject as? Container else { return @@ -370,7 +371,7 @@ private extension SidebarOutlineDataSource { destinationContainer.addFeed(existingFeed) { result in switch result { case .success: - sourceAccount.deleteFeed(feed) { result in + sourceAccount.deleteFeed(feed, from: sourceContainer) { result in BatchUpdate.shared.end() switch result { case .success: @@ -390,7 +391,7 @@ private extension SidebarOutlineDataSource { destinationAccount.createFeed(url: feed.url, name: feed.editedName, container: destinationContainer) { result in switch result { case .success: - sourceAccount.deleteFeed(feed) { result in + sourceAccount.deleteFeed(feed, from: sourceContainer) { result in BatchUpdate.shared.end() switch result { case .success: diff --git a/Mac/Scriptability/Account+Scriptability.swift b/Mac/Scriptability/Account+Scriptability.swift index 7c9e9c73c..f0ce08e22 100644 --- a/Mac/Scriptability/Account+Scriptability.swift +++ b/Mac/Scriptability/Account+Scriptability.swift @@ -55,7 +55,11 @@ class ScriptableAccount: NSObject, UniqueIdScriptingObject, ScriptingObjectConta } } else if let scriptableFeed = element as? ScriptableFeed { BatchUpdate.shared.perform { - account.deleteFeed(scriptableFeed.feed) { result in + var container: Container? = nil + if let scriptableFolder = scriptableFeed.container as? ScriptableFolder { + container = scriptableFolder.folder + } + account.deleteFeed(scriptableFeed.feed, from: container) { result in } } } diff --git a/Mac/Scriptability/Folder+Scriptability.swift b/Mac/Scriptability/Folder+Scriptability.swift index bd215f855..07e358407 100644 --- a/Mac/Scriptability/Folder+Scriptability.swift +++ b/Mac/Scriptability/Folder+Scriptability.swift @@ -53,7 +53,7 @@ class ScriptableFolder: NSObject, UniqueIdScriptingObject, ScriptingObjectContai func deleteElement(_ element:ScriptingObject) { if let scriptableFeed = element as? ScriptableFeed { BatchUpdate.shared.perform { - folder.account?.deleteFeed(scriptableFeed.feed) { result in } + folder.account?.deleteFeed(scriptableFeed.feed, from: folder) { result in } } } } diff --git a/Shared/Commands/DeleteCommand.swift b/Shared/Commands/DeleteCommand.swift index 309a8c8f0..cc3b5eac9 100644 --- a/Shared/Commands/DeleteCommand.swift +++ b/Shared/Commands/DeleteCommand.swift @@ -136,7 +136,7 @@ private struct SidebarItemSpecifier { if let feed = feed { BatchUpdate.shared.start() - account?.deleteFeed(feed) { result in + account?.deleteFeed(feed, from: path.resolveContainer()) { result in BatchUpdate.shared.end() self.checkResult(result) }