diff --git a/Mac/MainWindow/Sidebar/SidebarOutlineDataSource.swift b/Mac/MainWindow/Sidebar/SidebarOutlineDataSource.swift index ff8350fe1..6d8def52b 100644 --- a/Mac/MainWindow/Sidebar/SidebarOutlineDataSource.swift +++ b/Mac/MainWindow/Sidebar/SidebarOutlineDataSource.swift @@ -173,6 +173,9 @@ private extension SidebarOutlineDataSource { guard let dropTargetNode = ancestorThatCanAcceptLocalFeed(parentNode) else { return SidebarOutlineDataSource.dragOperationNone } + if nodeAndDraggedFeedsDoNotShareAccount(dropTargetNode, Set([draggedFeed])) { + return SidebarOutlineDataSource.dragOperationNone + } if nodeHasChildRepresentingDraggedFeed(dropTargetNode, draggedFeed) { return SidebarOutlineDataSource.dragOperationNone } @@ -191,6 +194,9 @@ private extension SidebarOutlineDataSource { guard let dropTargetNode = ancestorThatCanAcceptLocalFeed(parentNode) else { return SidebarOutlineDataSource.dragOperationNone } + if nodeAndDraggedFeedsDoNotShareAccount(dropTargetNode, draggedFeeds) { + return SidebarOutlineDataSource.dragOperationNone + } if nodeHasChildRepresentingAnyDraggedFeed(dropTargetNode, draggedFeeds) { return SidebarOutlineDataSource.dragOperationNone } @@ -321,6 +327,27 @@ private extension SidebarOutlineDataSource { } return false } + + func nodeAndDraggedFeedsDoNotShareAccount(_ parentNode: Node, _ draggedFeeds: Set) -> Bool { + + let parentAccountId: String? + if let account = parentNode.representedObject as? Account { + parentAccountId = account.accountID + } else if let folder = parentNode.representedObject as? Folder { + parentAccountId = folder.account?.accountID + } else { + return true + } + + for draggedFeed in draggedFeeds { + if draggedFeed.accountID != parentAccountId { + return true + } + } + + return false + + } func nodeHasChildRepresentingAnyDraggedFeed(_ parentNode: Node, _ draggedFeeds: Set) -> Bool { for node in parentNode.childNodes {