mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2025-02-09 08:39:00 +01:00
Add Clean Up command. Issue #1912
This commit is contained in:
parent
cba00b6d45
commit
0276c19459
@ -343,6 +343,12 @@
|
|||||||
<modifierMask key="keyEquivalentModifierMask"/>
|
<modifierMask key="keyEquivalentModifierMask"/>
|
||||||
<menu key="submenu" title="View" id="HyV-fh-RgO">
|
<menu key="submenu" title="View" id="HyV-fh-RgO">
|
||||||
<items>
|
<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">
|
<menuItem title="Hide Read Articles" id="b10-sA-Yzi">
|
||||||
<modifierMask key="keyEquivalentModifierMask"/>
|
<modifierMask key="keyEquivalentModifierMask"/>
|
||||||
<connections>
|
<connections>
|
||||||
|
@ -218,6 +218,10 @@ class MainWindowController : NSWindowController, NSUserInterfaceValidations {
|
|||||||
return currentSearchField != nil
|
return currentSearchField != nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if item.action == #selector(cleanUp(_:)) {
|
||||||
|
return validateCleanUp(item)
|
||||||
|
}
|
||||||
|
|
||||||
if item.action == #selector(toggleReadFeedsFilter(_:)) {
|
if item.action == #selector(toggleReadFeedsFilter(_:)) {
|
||||||
return validateToggleReadFeeds(item)
|
return validateToggleReadFeeds(item)
|
||||||
}
|
}
|
||||||
@ -438,6 +442,11 @@ class MainWindowController : NSWindowController, NSUserInterfaceValidations {
|
|||||||
window?.makeFirstResponder(searchField)
|
window?.makeFirstResponder(searchField)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@IBAction func cleanUp(_ sender: Any?) {
|
||||||
|
sidebarViewController?.cleanUp()
|
||||||
|
timelineContainerViewController?.cleanUp()
|
||||||
|
}
|
||||||
|
|
||||||
@IBAction func toggleReadFeedsFilter(_ sender: Any?) {
|
@IBAction func toggleReadFeedsFilter(_ sender: Any?) {
|
||||||
sidebarViewController?.toggleReadFilter()
|
sidebarViewController?.toggleReadFilter()
|
||||||
}
|
}
|
||||||
@ -872,6 +881,12 @@ private extension MainWindowController {
|
|||||||
return result
|
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 {
|
func validateToggleReadFeeds(_ item: NSValidatedUserInterfaceItem) -> Bool {
|
||||||
guard let menuItem = item as? NSMenuItem else { return false }
|
guard let menuItem = item as? NSMenuItem else { return false }
|
||||||
|
|
||||||
|
@ -447,6 +447,10 @@ protocol SidebarDelegate: class {
|
|||||||
rebuildTreeAndRestoreSelection()
|
rebuildTreeAndRestoreSelection()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func cleanUp() {
|
||||||
|
rebuildTreeAndRestoreSelection()
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - NSUserInterfaceValidations
|
// MARK: - NSUserInterfaceValidations
|
||||||
|
@ -89,6 +89,10 @@ final class TimelineContainerViewController: NSViewController {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func cleanUp() {
|
||||||
|
regularTimelineViewController.cleanUp()
|
||||||
|
}
|
||||||
|
|
||||||
func toggleReadFilter() {
|
func toggleReadFilter() {
|
||||||
regularTimelineViewController.toggleReadFilter()
|
regularTimelineViewController.toggleReadFilter()
|
||||||
}
|
}
|
||||||
|
@ -231,18 +231,15 @@ final class TimelineViewController: NSViewController, UndoableCommandRunner, Unr
|
|||||||
return representedObjects.first! === object
|
return representedObjects.first! === object
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func cleanUp() {
|
||||||
|
fetchAndReplacePreservingSelection()
|
||||||
|
}
|
||||||
|
|
||||||
func toggleReadFilter() {
|
func toggleReadFilter() {
|
||||||
guard let filter = isReadFiltered, let feedID = (representedObjects?.first as? Feed)?.feedID else { return }
|
guard let filter = isReadFiltered, let feedID = (representedObjects?.first as? Feed)?.feedID else { return }
|
||||||
readFilterEnabledTable[feedID] = !filter
|
readFilterEnabledTable[feedID] = !filter
|
||||||
delegate?.timelineInvalidatedRestorationState(self)
|
delegate?.timelineInvalidatedRestorationState(self)
|
||||||
|
fetchAndReplacePreservingSelection()
|
||||||
if let article = oneSelectedArticle, let account = article.account {
|
|
||||||
exceptionArticleFetcher = SingleArticleFetcher(account: account, articleID: article.articleID)
|
|
||||||
}
|
|
||||||
|
|
||||||
performBlockAndRestoreSelection {
|
|
||||||
fetchAndReplaceArticlesSync()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: State Restoration
|
// 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() {
|
@objc func reloadAvailableCells() {
|
||||||
if let indexesToReload = tableView.indexesOfAvailableRows() {
|
if let indexesToReload = tableView.indexesOfAvailableRows() {
|
||||||
reloadCells(for: indexesToReload)
|
reloadCells(for: indexesToReload)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user