Add Clean Up command. Issue #1912
This commit is contained in:
parent
cba00b6d45
commit
0276c19459
|
@ -343,6 +343,12 @@
|
|||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<menu key="submenu" title="View" id="HyV-fh-RgO">
|
||||
<items>
|
||||
<menuItem title="Clean Up" keyEquivalent="H" id="J5h-uQ-57w">
|
||||
<connections>
|
||||
<action selector="cleanUp:" target="Ady-hI-5gd" id="eNB-UA-e3a"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem isSeparatorItem="YES" id="rcJ-r3-Y2U"/>
|
||||
<menuItem title="Hide Read Articles" id="b10-sA-Yzi">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
|
|
|
@ -218,6 +218,10 @@ class MainWindowController : NSWindowController, NSUserInterfaceValidations {
|
|||
return currentSearchField != nil
|
||||
}
|
||||
|
||||
if item.action == #selector(cleanUp(_:)) {
|
||||
return validateCleanUp(item)
|
||||
}
|
||||
|
||||
if item.action == #selector(toggleReadFeedsFilter(_:)) {
|
||||
return validateToggleReadFeeds(item)
|
||||
}
|
||||
|
@ -438,6 +442,11 @@ class MainWindowController : NSWindowController, NSUserInterfaceValidations {
|
|||
window?.makeFirstResponder(searchField)
|
||||
}
|
||||
|
||||
@IBAction func cleanUp(_ sender: Any?) {
|
||||
sidebarViewController?.cleanUp()
|
||||
timelineContainerViewController?.cleanUp()
|
||||
}
|
||||
|
||||
@IBAction func toggleReadFeedsFilter(_ sender: Any?) {
|
||||
sidebarViewController?.toggleReadFilter()
|
||||
}
|
||||
|
@ -872,6 +881,12 @@ private extension MainWindowController {
|
|||
return result
|
||||
}
|
||||
|
||||
func validateCleanUp(_ item: NSValidatedUserInterfaceItem) -> Bool {
|
||||
let isSidebarFiltered = sidebarViewController?.isReadFiltered ?? false
|
||||
let isTimelineFiltered = timelineContainerViewController?.isReadFiltered ?? false
|
||||
return isSidebarFiltered || isTimelineFiltered
|
||||
}
|
||||
|
||||
func validateToggleReadFeeds(_ item: NSValidatedUserInterfaceItem) -> Bool {
|
||||
guard let menuItem = item as? NSMenuItem else { return false }
|
||||
|
||||
|
|
|
@ -446,6 +446,10 @@ protocol SidebarDelegate: class {
|
|||
delegate?.sidebarInvalidatedRestorationState(self)
|
||||
rebuildTreeAndRestoreSelection()
|
||||
}
|
||||
|
||||
func cleanUp() {
|
||||
rebuildTreeAndRestoreSelection()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -89,6 +89,10 @@ final class TimelineContainerViewController: NSViewController {
|
|||
return true
|
||||
}
|
||||
|
||||
func cleanUp() {
|
||||
regularTimelineViewController.cleanUp()
|
||||
}
|
||||
|
||||
func toggleReadFilter() {
|
||||
regularTimelineViewController.toggleReadFilter()
|
||||
}
|
||||
|
|
|
@ -230,19 +230,16 @@ final class TimelineViewController: NSViewController, UndoableCommandRunner, Unr
|
|||
}
|
||||
return representedObjects.first! === object
|
||||
}
|
||||
|
||||
func cleanUp() {
|
||||
fetchAndReplacePreservingSelection()
|
||||
}
|
||||
|
||||
func toggleReadFilter() {
|
||||
guard let filter = isReadFiltered, let feedID = (representedObjects?.first as? Feed)?.feedID else { return }
|
||||
readFilterEnabledTable[feedID] = !filter
|
||||
delegate?.timelineInvalidatedRestorationState(self)
|
||||
|
||||
if let article = oneSelectedArticle, let account = article.account {
|
||||
exceptionArticleFetcher = SingleArticleFetcher(account: account, articleID: article.articleID)
|
||||
}
|
||||
|
||||
performBlockAndRestoreSelection {
|
||||
fetchAndReplaceArticlesSync()
|
||||
}
|
||||
fetchAndReplacePreservingSelection()
|
||||
}
|
||||
|
||||
// MARK: State Restoration
|
||||
|
@ -919,6 +916,15 @@ private extension TimelineViewController {
|
|||
}
|
||||
}
|
||||
|
||||
func fetchAndReplacePreservingSelection() {
|
||||
if let article = oneSelectedArticle, let account = article.account {
|
||||
exceptionArticleFetcher = SingleArticleFetcher(account: account, articleID: article.articleID)
|
||||
}
|
||||
performBlockAndRestoreSelection {
|
||||
fetchAndReplaceArticlesSync()
|
||||
}
|
||||
}
|
||||
|
||||
@objc func reloadAvailableCells() {
|
||||
if let indexesToReload = tableView.indexesOfAvailableRows() {
|
||||
reloadCells(for: indexesToReload)
|
||||
|
|
Loading…
Reference in New Issue