Don't allow a feed to be in more than one folder for Reader API accounts
This commit is contained in:
parent
51d74eaf45
commit
cbb481c3f7
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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<PasteboardWebFeed>) -> 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)
|
||||
|
|
Loading…
Reference in New Issue