mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2025-02-08 16:18:48 +01:00
Correct how feeds were deleted so that only the feed in the correct container was deleted
This commit is contained in:
parent
bead6ae123
commit
5e3fcfd955
@ -396,9 +396,9 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public func deleteFeed(_ feed: Feed, completion: @escaping (Result<Void, Error>) -> Void) {
|
public func deleteFeed(_ feed: Feed, from container: Container?, completion: @escaping (Result<Void, Error>) -> Void) {
|
||||||
feedMetadata[feed.url] = nil
|
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, Error>) -> Void) {
|
public func renameFeed(_ feed: Feed, to name: String, completion: @escaping (Result<Void, Error>) -> Void) {
|
||||||
|
@ -34,7 +34,7 @@ protocol AccountDelegate {
|
|||||||
|
|
||||||
func createFeed(for account: Account, url: String, name: String?, container: Container, completion: @escaping (Result<Feed, Error>) -> Void)
|
func createFeed(for account: Account, url: String, name: String?, container: Container, completion: @escaping (Result<Feed, Error>) -> Void)
|
||||||
func renameFeed(for account: Account, with feed: Feed, to name: String, completion: @escaping (Result<Void, Error>) -> Void)
|
func renameFeed(for account: Account, with feed: Feed, to name: String, completion: @escaping (Result<Void, Error>) -> Void)
|
||||||
func deleteFeed(for account: Account, with feed: Feed, completion: @escaping (Result<Void, Error>) -> Void)
|
func deleteFeed(for account: Account, with feed: Feed, from container: Container?, completion: @escaping (Result<Void, Error>) -> Void)
|
||||||
|
|
||||||
func addFeed(for account: Account, to container: Container, with: Feed, completion: @escaping (Result<Void, Error>) -> Void)
|
func addFeed(for account: Account, to container: Container, with: Feed, completion: @escaping (Result<Void, Error>) -> Void)
|
||||||
func removeFeed(for account: Account, from container: Container, with: Feed, completion: @escaping (Result<Void, Error>) -> Void)
|
func removeFeed(for account: Account, from container: Container, with: Feed, completion: @escaping (Result<Void, Error>) -> Void)
|
||||||
|
@ -340,7 +340,7 @@ final class FeedbinAccountDelegate: AccountDelegate {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func deleteFeed(for account: Account, with feed: Feed, completion: @escaping (Result<Void, Error>) -> Void) {
|
func deleteFeed(for account: Account, with feed: Feed, from container: Container?, completion: @escaping (Result<Void, Error>) -> Void) {
|
||||||
|
|
||||||
// This error should never happen
|
// This error should never happen
|
||||||
guard let subscriptionID = feed.subscriptionID else {
|
guard let subscriptionID = feed.subscriptionID else {
|
||||||
|
@ -122,8 +122,7 @@ final class LocalAccountDelegate: AccountDelegate {
|
|||||||
completion(.success(()))
|
completion(.success(()))
|
||||||
}
|
}
|
||||||
|
|
||||||
func deleteFeed(for account: Account, from container: Container, feed: Feed, completion: @escaping (Result<Void, Error>) -> Void) {
|
func deleteFeed(for account: Account, with feed: Feed, from container: Container?, completion: @escaping (Result<Void, Error>) -> Void) {
|
||||||
|
|
||||||
if let account = container as? Account {
|
if let account = container as? Account {
|
||||||
account.removeFeed(feed)
|
account.removeFeed(feed)
|
||||||
}
|
}
|
||||||
@ -131,17 +130,6 @@ final class LocalAccountDelegate: AccountDelegate {
|
|||||||
folder.removeFeed(feed)
|
folder.removeFeed(feed)
|
||||||
}
|
}
|
||||||
completion(.success(()))
|
completion(.success(()))
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func deleteFeed(for account: Account, with feed: Feed, completion: @escaping (Result<Void, Error>) -> 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, Error>) -> Void) {
|
func addFeed(for account: Account, to container: Container, with feed: Feed, completion: @escaping (Result<Void, Error>) -> Void) {
|
||||||
|
@ -359,6 +359,7 @@ private extension SidebarOutlineDataSource {
|
|||||||
func moveBetweenAccounts(node: Node, to parentNode: Node) {
|
func moveBetweenAccounts(node: Node, to parentNode: Node) {
|
||||||
guard let feed = node.representedObject as? Feed,
|
guard let feed = node.representedObject as? Feed,
|
||||||
let sourceAccount = nodeAccount(node),
|
let sourceAccount = nodeAccount(node),
|
||||||
|
let sourceContainer = node.parent?.representedObject as? Container,
|
||||||
let destinationAccount = nodeAccount(parentNode),
|
let destinationAccount = nodeAccount(parentNode),
|
||||||
let destinationContainer = parentNode.representedObject as? Container else {
|
let destinationContainer = parentNode.representedObject as? Container else {
|
||||||
return
|
return
|
||||||
@ -370,7 +371,7 @@ private extension SidebarOutlineDataSource {
|
|||||||
destinationContainer.addFeed(existingFeed) { result in
|
destinationContainer.addFeed(existingFeed) { result in
|
||||||
switch result {
|
switch result {
|
||||||
case .success:
|
case .success:
|
||||||
sourceAccount.deleteFeed(feed) { result in
|
sourceAccount.deleteFeed(feed, from: sourceContainer) { result in
|
||||||
BatchUpdate.shared.end()
|
BatchUpdate.shared.end()
|
||||||
switch result {
|
switch result {
|
||||||
case .success:
|
case .success:
|
||||||
@ -390,7 +391,7 @@ private extension SidebarOutlineDataSource {
|
|||||||
destinationAccount.createFeed(url: feed.url, name: feed.editedName, container: destinationContainer) { result in
|
destinationAccount.createFeed(url: feed.url, name: feed.editedName, container: destinationContainer) { result in
|
||||||
switch result {
|
switch result {
|
||||||
case .success:
|
case .success:
|
||||||
sourceAccount.deleteFeed(feed) { result in
|
sourceAccount.deleteFeed(feed, from: sourceContainer) { result in
|
||||||
BatchUpdate.shared.end()
|
BatchUpdate.shared.end()
|
||||||
switch result {
|
switch result {
|
||||||
case .success:
|
case .success:
|
||||||
|
@ -55,7 +55,11 @@ class ScriptableAccount: NSObject, UniqueIdScriptingObject, ScriptingObjectConta
|
|||||||
}
|
}
|
||||||
} else if let scriptableFeed = element as? ScriptableFeed {
|
} else if let scriptableFeed = element as? ScriptableFeed {
|
||||||
BatchUpdate.shared.perform {
|
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ class ScriptableFolder: NSObject, UniqueIdScriptingObject, ScriptingObjectContai
|
|||||||
func deleteElement(_ element:ScriptingObject) {
|
func deleteElement(_ element:ScriptingObject) {
|
||||||
if let scriptableFeed = element as? ScriptableFeed {
|
if let scriptableFeed = element as? ScriptableFeed {
|
||||||
BatchUpdate.shared.perform {
|
BatchUpdate.shared.perform {
|
||||||
folder.account?.deleteFeed(scriptableFeed.feed) { result in }
|
folder.account?.deleteFeed(scriptableFeed.feed, from: folder) { result in }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -136,7 +136,7 @@ private struct SidebarItemSpecifier {
|
|||||||
|
|
||||||
if let feed = feed {
|
if let feed = feed {
|
||||||
BatchUpdate.shared.start()
|
BatchUpdate.shared.start()
|
||||||
account?.deleteFeed(feed) { result in
|
account?.deleteFeed(feed, from: path.resolveContainer()) { result in
|
||||||
BatchUpdate.shared.end()
|
BatchUpdate.shared.end()
|
||||||
self.checkResult(result)
|
self.checkResult(result)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user