diff --git a/Account/Sources/Account/AccountBehaviors.swift b/Account/Sources/Account/AccountBehaviors.swift index 90776cdd3..fed082b4c 100644 --- a/Account/Sources/Account/AccountBehaviors.swift +++ b/Account/Sources/Account/AccountBehaviors.swift @@ -28,6 +28,11 @@ public enum AccountBehavior: Equatable { */ case disallowFeedInRootFolder + /** + Account doesn't support a feed being in more than one folder. + */ + case disallowFeedInMultipleFolders + /** Account doesn't support folders */ diff --git a/Account/Sources/Account/ReaderAPI/ReaderAPIAccountDelegate.swift b/Account/Sources/Account/ReaderAPI/ReaderAPIAccountDelegate.swift index 60eeecd14..8d9310cc8 100644 --- a/Account/Sources/Account/ReaderAPI/ReaderAPIAccountDelegate.swift +++ b/Account/Sources/Account/ReaderAPI/ReaderAPIAccountDelegate.swift @@ -29,7 +29,7 @@ final class ReaderAPIAccountDelegate: AccountDelegate { private var log = OSLog(subsystem: Bundle.main.bundleIdentifier!, category: "ReaderAPI") var behaviors: AccountBehaviors { - var behaviors: AccountBehaviors = [.disallowOPMLImports] + var behaviors: AccountBehaviors = [.disallowOPMLImports, .disallowFeedInMultipleFolders] if variant == .freshRSS { behaviors.append(.disallowFeedInRootFolder) } diff --git a/Mac/MainWindow/Sidebar/SidebarOutlineDataSource.swift b/Mac/MainWindow/Sidebar/SidebarOutlineDataSource.swift index ec919b073..df593b664 100644 --- a/Mac/MainWindow/Sidebar/SidebarOutlineDataSource.swift +++ b/Mac/MainWindow/Sidebar/SidebarOutlineDataSource.swift @@ -644,6 +644,10 @@ private extension SidebarOutlineDataSource { return true } + if violatesDisallowFeedInMultipleFolders(parentNode, draggedFeeds) { + return true + } + return false } @@ -677,6 +681,20 @@ private extension SidebarOutlineDataSource { return false } + func violatesDisallowFeedInMultipleFolders(_ parentNode: Node, _ draggedFeeds: Set) -> Bool { + guard let parentAccount = nodeAccount(parentNode), parentAccount.behaviors.contains(.disallowFeedInMultipleFolders) else { + return false + } + + for draggedFeed in draggedFeeds { + if parentAccount.hasWebFeed(withURL: draggedFeed.url) { + return true + } + } + + return false + } + func indexWhereDraggedFeedWouldAppear(_ parentNode: Node, _ draggedFeed: PasteboardWebFeed) -> Int { let draggedFeedWrapper = PasteboardFeedObjectWrapper(pasteboardFeed: draggedFeed) let draggedFeedNode = Node(representedObject: draggedFeedWrapper, parent: nil)