mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2024-12-28 02:20:54 +01:00
Implement disallowing feeds in the root folder for specified accounts
This commit is contained in:
parent
a85df5bd09
commit
1bcc1eda44
@ -16,15 +16,21 @@ class FolderTreeMenu {
|
||||
static func createFolderPopupMenu(with rootNode: Node) -> NSMenu {
|
||||
|
||||
let menu = NSMenu(title: "Folders")
|
||||
menu.autoenablesItems = false
|
||||
|
||||
for childNode in rootNode.childNodes {
|
||||
|
||||
guard let nameProvider = childNode.representedObject as? DisplayNameProvider else {
|
||||
guard let account = childNode.representedObject as? Account else {
|
||||
continue
|
||||
}
|
||||
|
||||
let menuItem = NSMenuItem(title: nameProvider.nameForDisplay, action: nil, keyEquivalent: "")
|
||||
let menuItem = NSMenuItem(title: account.nameForDisplay, action: nil, keyEquivalent: "")
|
||||
menuItem.representedObject = childNode.representedObject
|
||||
|
||||
if account.behaviors.contains(.disallowFeedInRootFolder) {
|
||||
menuItem.isEnabled = false
|
||||
}
|
||||
|
||||
menu.addItem(menuItem)
|
||||
|
||||
let childNodes = childNode.childNodes
|
||||
|
@ -636,6 +636,30 @@ private extension SidebarOutlineDataSource {
|
||||
}
|
||||
|
||||
func violatesAccountSpecificBehavior(_ parentNode: Node, _ draggedFeeds: Set<PasteboardFeed>) -> Bool {
|
||||
if violatesDisallowFeedInRootFolder(parentNode) {
|
||||
return true
|
||||
}
|
||||
|
||||
if violatesDisallowFeedCopyInRootFolder(parentNode, draggedFeeds) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func violatesDisallowFeedInRootFolder(_ parentNode: Node) -> Bool {
|
||||
guard let parentAccount = nodeAccount(parentNode), parentAccount.behaviors.contains(.disallowFeedInRootFolder) else {
|
||||
return false
|
||||
}
|
||||
|
||||
if parentNode.representedObject is Account {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func violatesDisallowFeedCopyInRootFolder(_ parentNode: Node, _ draggedFeeds: Set<PasteboardFeed>) -> Bool {
|
||||
guard let parentAccount = nodeAccount(parentNode), parentAccount.behaviors.contains(.disallowFeedCopyInRootFolder) else {
|
||||
return false
|
||||
}
|
||||
@ -646,14 +670,13 @@ private extension SidebarOutlineDataSource {
|
||||
}
|
||||
}
|
||||
|
||||
// Can't copy to the account when using tags
|
||||
if parentNode.representedObject is Account && (NSApplication.shared.currentEvent?.modifierFlags.contains(.option) ?? false) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
func indexWhereDraggedFeedWouldAppear(_ parentNode: Node, _ draggedFeed: PasteboardFeed) -> Int {
|
||||
let draggedFeedWrapper = PasteboardFeedObjectWrapper(pasteboardFeed: draggedFeed)
|
||||
let draggedFeedNode = Node(representedObject: draggedFeedWrapper, parent: nil)
|
||||
|
Loading…
Reference in New Issue
Block a user