Do misc. minor cleanups in SidebarViewController.
This commit is contained in:
parent
39afef3db8
commit
c0d7a87231
|
@ -7,8 +7,27 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
import AppKit
|
import AppKit
|
||||||
|
import Data
|
||||||
|
import Account
|
||||||
|
|
||||||
protocol SmallIconProvider {
|
protocol SmallIconProvider {
|
||||||
|
|
||||||
var smallIcon: NSImage? { get }
|
var smallIcon: NSImage? { get }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension Feed: SmallIconProvider {
|
||||||
|
|
||||||
|
var smallIcon: NSImage? {
|
||||||
|
if let image = appDelegate.faviconDownloader.favicon(for: self) {
|
||||||
|
return image
|
||||||
|
}
|
||||||
|
return AppImages.genericFeedImage
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension Folder: SmallIconProvider {
|
||||||
|
|
||||||
|
var smallIcon: NSImage? {
|
||||||
|
return NSImage(named: NSImage.Name.folder)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ import RSCore
|
||||||
return selectedNodes.representedObjects()
|
return selectedNodes.representedObjects()
|
||||||
}
|
}
|
||||||
|
|
||||||
//MARK: NSViewController
|
// MARK: - NSViewController
|
||||||
|
|
||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
|
|
||||||
|
@ -70,9 +70,9 @@ import RSCore
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//MARK: Notifications
|
// MARK: - Notifications
|
||||||
|
|
||||||
@objc dynamic func unreadCountDidChange(_ note: Notification) {
|
@objc func unreadCountDidChange(_ note: Notification) {
|
||||||
|
|
||||||
guard let representedObject = note.object else {
|
guard let representedObject = note.object else {
|
||||||
return
|
return
|
||||||
|
@ -80,17 +80,17 @@ import RSCore
|
||||||
configureUnreadCountForCellsForRepresentedObject(representedObject as AnyObject)
|
configureUnreadCountForCellsForRepresentedObject(representedObject as AnyObject)
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc dynamic func containerChildrenDidChange(_ note: Notification) {
|
@objc func containerChildrenDidChange(_ note: Notification) {
|
||||||
|
|
||||||
rebuildTreeAndReloadDataIfNeeded()
|
rebuildTreeAndReloadDataIfNeeded()
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc dynamic func batchUpdateDidPerform(_ notification: Notification) {
|
@objc func batchUpdateDidPerform(_ notification: Notification) {
|
||||||
|
|
||||||
rebuildTreeAndReloadDataIfNeeded()
|
rebuildTreeAndReloadDataIfNeeded()
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc dynamic func userDidAddFeed(_ notification: Notification) {
|
@objc func userDidAddFeed(_ notification: Notification) {
|
||||||
|
|
||||||
guard let feed = notification.userInfo?[UserInfoKey.feed] else {
|
guard let feed = notification.userInfo?[UserInfoKey.feed] else {
|
||||||
return
|
return
|
||||||
|
@ -119,7 +119,7 @@ import RSCore
|
||||||
configureCellsForRepresentedObject(object as AnyObject)
|
configureCellsForRepresentedObject(object as AnyObject)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: Actions
|
// MARK: - Actions
|
||||||
|
|
||||||
@IBAction func delete(_ sender: AnyObject?) {
|
@IBAction func delete(_ sender: AnyObject?) {
|
||||||
|
|
||||||
|
@ -175,7 +175,7 @@ import RSCore
|
||||||
NSPasteboard.general.copyObjects(selectedObjects)
|
NSPasteboard.general.copyObjects(selectedObjects)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: Navigation
|
// MARK: - Navigation
|
||||||
|
|
||||||
func canGoToNextUnread() -> Bool {
|
func canGoToNextUnread() -> Bool {
|
||||||
|
|
||||||
|
@ -203,7 +203,7 @@ import RSCore
|
||||||
window.makeFirstResponderUnlessDescendantIsFirstResponder(outlineView)
|
window.makeFirstResponderUnlessDescendantIsFirstResponder(outlineView)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: Contextual Menu
|
// MARK: - Contextual Menu
|
||||||
|
|
||||||
func contextualMenuForSelectedObjects() -> NSMenu? {
|
func contextualMenuForSelectedObjects() -> NSMenu? {
|
||||||
|
|
||||||
|
@ -226,7 +226,7 @@ import RSCore
|
||||||
return menu(for: [object])
|
return menu(for: [object])
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: NSOutlineViewDelegate
|
// MARK: - NSOutlineViewDelegate
|
||||||
|
|
||||||
func outlineView(_ outlineView: NSOutlineView, viewFor tableColumn: NSTableColumn?, item: Any) -> NSView? {
|
func outlineView(_ outlineView: NSOutlineView, viewFor tableColumn: NSTableColumn?, item: Any) -> NSView? {
|
||||||
|
|
||||||
|
@ -570,20 +570,4 @@ private extension SidebarViewController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Feed: SmallIconProvider {
|
|
||||||
|
|
||||||
var smallIcon: NSImage? {
|
|
||||||
if let image = appDelegate.faviconDownloader.favicon(for: self) {
|
|
||||||
return image
|
|
||||||
}
|
|
||||||
return AppImages.genericFeedImage
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
extension Folder: SmallIconProvider {
|
|
||||||
|
|
||||||
var smallIcon: NSImage? {
|
|
||||||
return NSImage(named: NSImage.Name.folder)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue