From 51284b5aa4e6f8cc5dc0c7299d6ab8af7fea9bd6 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Wed, 29 May 2019 21:04:44 -0500 Subject: [PATCH] Rename deleteFeed to removeFeed to be more consistent with other API's --- Frameworks/Account/Account.swift | 10 +++------- Frameworks/Account/AccountDelegate.swift | 5 ++--- .../Account/Feedbin/FeedbinAccountDelegate.swift | 6 +++--- .../Account/LocalAccount/LocalAccountDelegate.swift | 9 ++------- Mac/MainWindow/Sidebar/SidebarOutlineDataSource.swift | 4 ++-- Mac/Scriptability/Account+Scriptability.swift | 2 +- Mac/Scriptability/Folder+Scriptability.swift | 2 +- Shared/Commands/DeleteCommand.swift | 2 +- 8 files changed, 15 insertions(+), 25 deletions(-) diff --git a/Frameworks/Account/Account.swift b/Frameworks/Account/Account.swift index bcd4a61ab..6134a34b2 100644 --- a/Frameworks/Account/Account.swift +++ b/Frameworks/Account/Account.swift @@ -377,13 +377,9 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container, } public func addFeed(_ feed: Feed, to container: Container, completion: @escaping (Result) -> Void) { - delegate.addFeed(for: self, to: container, with: feed, completion: completion) + delegate.addFeed(for: self, with: feed, to: container, completion: completion) } - public func removeFeed(_ feed: Feed, from container: Container, completion: @escaping (Result) -> Void) { - delegate.removeFeed(for: self, from: container, with: feed, completion: completion) - } - public func createFeed(url: String, name: String?, container: Container, completion: @escaping (Result) -> Void) { delegate.createFeed(for: self, url: url, name: name, container: container, completion: completion) } @@ -399,9 +395,9 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container, } - public func deleteFeed(_ feed: Feed, from container: Container?, completion: @escaping (Result) -> Void) { + public func removeFeed(_ feed: Feed, from container: Container?, completion: @escaping (Result) -> Void) { feedMetadata[feed.url] = nil - delegate.deleteFeed(for: self, with: feed, from: container, completion: completion) + delegate.removeFeed(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 01eb15e7f..3bf3ff1c4 100644 --- a/Frameworks/Account/AccountDelegate.swift +++ b/Frameworks/Account/AccountDelegate.swift @@ -34,10 +34,9 @@ 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, from container: Container?, completion: @escaping (Result) -> Void) + func addFeed(for account: Account, with: Feed, to container: Container, completion: @escaping (Result) -> Void) + func removeFeed(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) func restoreFeed(for account: Account, feed: Feed, container: Container, completion: @escaping (Result) -> Void) func restoreFolder(for account: Account, folder: Folder, completion: @escaping (Result) -> Void) diff --git a/Frameworks/Account/Feedbin/FeedbinAccountDelegate.swift b/Frameworks/Account/Feedbin/FeedbinAccountDelegate.swift index 621e3093a..47d5cccb9 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, from container: Container?, completion: @escaping (Result) -> Void) { + func removeFeed(for account: Account, with feed: Feed, from container: Container?, completion: @escaping (Result) -> Void) { // This error should never happen guard let subscriptionID = feed.subscriptionID else { @@ -370,7 +370,7 @@ final class FeedbinAccountDelegate: AccountDelegate { } - func addFeed(for account: Account, to container: Container, with feed: Feed, completion: @escaping (Result) -> Void) { + func addFeed(for account: Account, with feed: Feed, to container: Container, completion: @escaping (Result) -> Void) { if let folder = container as? Folder, let feedID = Int(feed.feedID) { caller.createTagging(feedID: feedID, name: folder.name ?? "") { result in @@ -448,7 +448,7 @@ final class FeedbinAccountDelegate: AccountDelegate { for feed in folder.topLevelFeeds { group.enter() - addFeed(for: account, to: folder, with: feed) { result in + addFeed(for: account, with: feed, to: folder) { result in if account.topLevelFeeds.contains(feed) { account.removeFeed(feed) } diff --git a/Frameworks/Account/LocalAccount/LocalAccountDelegate.swift b/Frameworks/Account/LocalAccount/LocalAccountDelegate.swift index d1fe5f84e..313c058f9 100644 --- a/Frameworks/Account/LocalAccount/LocalAccountDelegate.swift +++ b/Frameworks/Account/LocalAccount/LocalAccountDelegate.swift @@ -122,21 +122,16 @@ final class LocalAccountDelegate: AccountDelegate { completion(.success(())) } - func deleteFeed(for account: Account, with feed: Feed, from container: Container?, completion: @escaping (Result) -> Void) { + func removeFeed(for account: Account, with feed: Feed, from container: Container?, completion: @escaping (Result) -> Void) { container?.removeFeed(feed) completion(.success(())) } - func addFeed(for account: Account, to container: Container, with feed: Feed, completion: @escaping (Result) -> Void) { + func addFeed(for account: Account, with feed: Feed, to container: Container, completion: @escaping (Result) -> Void) { container.addFeed(feed) completion(.success(())) } - func removeFeed(for account: Account, from container: Container, with feed: Feed, completion: @escaping (Result) -> Void) { - container.removeFeed(feed) - completion(.success(())) - } - func restoreFeed(for account: Account, feed: Feed, container: Container, completion: @escaping (Result) -> Void) { if let folder = container as? Folder { folder.addFeed(feed) diff --git a/Mac/MainWindow/Sidebar/SidebarOutlineDataSource.swift b/Mac/MainWindow/Sidebar/SidebarOutlineDataSource.swift index 8c3ecea0e..dafd0d01b 100644 --- a/Mac/MainWindow/Sidebar/SidebarOutlineDataSource.swift +++ b/Mac/MainWindow/Sidebar/SidebarOutlineDataSource.swift @@ -368,7 +368,7 @@ private extension SidebarOutlineDataSource { destinationAccount.addFeed(existingFeed, to: destinationContainer) { result in switch result { case .success: - sourceAccount.deleteFeed(feed, from: sourceContainer) { result in + sourceAccount.removeFeed(feed, from: sourceContainer) { result in BatchUpdate.shared.end() switch result { case .success: @@ -388,7 +388,7 @@ private extension SidebarOutlineDataSource { destinationAccount.createFeed(url: feed.url, name: feed.editedName, container: destinationContainer) { result in switch result { case .success: - sourceAccount.deleteFeed(feed, from: sourceContainer) { result in + sourceAccount.removeFeed(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 3647282e3..80637f6be 100644 --- a/Mac/Scriptability/Account+Scriptability.swift +++ b/Mac/Scriptability/Account+Scriptability.swift @@ -59,7 +59,7 @@ class ScriptableAccount: NSObject, UniqueIdScriptingObject, ScriptingObjectConta if let scriptableFolder = scriptableFeed.container as? ScriptableFolder { container = scriptableFolder.folder } - account.deleteFeed(scriptableFeed.feed, from: container) { result in + account.removeFeed(scriptableFeed.feed, from: container) { result in } } } diff --git a/Mac/Scriptability/Folder+Scriptability.swift b/Mac/Scriptability/Folder+Scriptability.swift index 07e358407..a5ea88618 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, from: folder) { result in } + folder.account?.removeFeed(scriptableFeed.feed, from: folder) { result in } } } } diff --git a/Shared/Commands/DeleteCommand.swift b/Shared/Commands/DeleteCommand.swift index f35ce5c75..6a8a15a5d 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, from: path.resolveContainer()) { result in + account?.removeFeed(feed, from: path.resolveContainer()) { result in BatchUpdate.shared.end() self.checkResult(result) }