From dac4c2ffb05b75e7770692dfc88259e4267d20a2 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Sat, 29 Feb 2020 16:24:14 -0800 Subject: [PATCH] Disclose feed in side bar when selected from context menu even if the feed is filtered. Issue #1805 --- Mac/MainWindow/MainWindowController.swift | 2 +- .../Sidebar/SidebarViewController.swift | 23 +++++++++++++++---- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/Mac/MainWindow/MainWindowController.swift b/Mac/MainWindow/MainWindowController.swift index 6ea22ca91..39a7c3000 100644 --- a/Mac/MainWindow/MainWindowController.swift +++ b/Mac/MainWindow/MainWindowController.swift @@ -516,7 +516,7 @@ extension MainWindowController: TimelineContainerViewControllerDelegate { } func timelineRequestedWebFeedSelection(_: TimelineContainerViewController, webFeed: WebFeed) { - sidebarViewController?.selectWebFeed(webFeed) + sidebarViewController?.selectFeed(webFeed) } } diff --git a/Mac/MainWindow/Sidebar/SidebarViewController.swift b/Mac/MainWindow/Sidebar/SidebarViewController.swift index 177f4d325..08a897900 100644 --- a/Mac/MainWindow/Sidebar/SidebarViewController.swift +++ b/Mac/MainWindow/Sidebar/SidebarViewController.swift @@ -329,15 +329,30 @@ protocol SidebarDelegate: class { // MARK: - API - func selectWebFeed(_ webFeed: WebFeed) { - revealAndSelectRepresentedObject(webFeed as AnyObject) + func selectFeed(_ feed: Feed) { + if isReadFiltered, let feedID = feed.feedID { + self.treeControllerDelegate.addFilterException(feedID) + + if let webFeed = feed as? WebFeed, let account = webFeed.account { + let parentFolder = account.sortedFolders?.first(where: { $0.objectIsChild(webFeed) }) + if let parentFolderFeedID = parentFolder?.feedID { + self.treeControllerDelegate.addFilterException(parentFolderFeedID) + } + } + + rebuildTreeAndRestoreSelection() + } + + revealAndSelectRepresentedObject(feed as AnyObject) } func deepLinkRevealAndSelect(for userInfo: [AnyHashable : Any]) { - guard let accountNode = findAccountNode(userInfo), let feedNode = findFeedNode(userInfo, beginningAt: accountNode) else { + guard let accountNode = findAccountNode(userInfo), + let feedNode = findFeedNode(userInfo, beginningAt: accountNode), + let feed = feedNode.representedObject as? Feed else { return } - revealAndSelectRepresentedObject(feedNode.representedObject) + selectFeed(feed) } func toggleReadFilter() {