Note when feed settings change and update the sidebar cells.
This commit is contained in:
parent
16f1791b95
commit
68c01491fc
|
@ -38,6 +38,7 @@ import RSCore
|
|||
NotificationCenter.default.addObserver(self, selector: #selector(userDidAddFeed(_:)), name: .UserDidAddFeed, object: nil)
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(batchUpdateDidPerform(_:)), name: .BatchUpdateDidPerform, object: nil)
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(faviconDidBecomeAvailable(_:)), name: .FaviconDidBecomeAvailable, object: nil)
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(feedSettingDidChange(_:)), name: .FeedSettingDidChange, object: nil)
|
||||
|
||||
outlineView.reloadData()
|
||||
|
||||
|
@ -62,7 +63,7 @@ import RSCore
|
|||
guard let representedObject = note.object else {
|
||||
return
|
||||
}
|
||||
let _ = configureCellsForRepresentedObject(representedObject as AnyObject)
|
||||
configureCellsForRepresentedObject(representedObject as AnyObject)
|
||||
}
|
||||
|
||||
@objc dynamic func containerChildrenDidChange(_ note: Notification) {
|
||||
|
@ -88,6 +89,14 @@ import RSCore
|
|||
configureAvailableCells()
|
||||
}
|
||||
|
||||
@objc func feedSettingDidChange(_ note: Notification) {
|
||||
|
||||
guard let feed = note.object as? Feed else {
|
||||
return
|
||||
}
|
||||
configureCellsForRepresentedObject(feed)
|
||||
}
|
||||
|
||||
// MARK: Actions
|
||||
|
||||
@IBAction func delete(_ sender: AnyObject?) {
|
||||
|
@ -405,9 +414,10 @@ private extension SidebarViewController {
|
|||
}
|
||||
}
|
||||
|
||||
@discardableResult
|
||||
func configureCellsForRepresentedObject(_ representedObject: AnyObject) -> Bool {
|
||||
|
||||
//Return true if any cells were configured.
|
||||
// Return true if any cells were configured.
|
||||
|
||||
let cells = cellsForRepresentedObject(representedObject)
|
||||
if cells.isEmpty {
|
||||
|
|
|
@ -134,6 +134,8 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
|
|||
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(batchUpdateDidPerform(_:)), name: .BatchUpdateDidPerform, object: nil)
|
||||
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(feedSettingDidChange(_:)), name: .FeedSettingDidChange, object: nil)
|
||||
|
||||
pullObjectsFromDisk()
|
||||
|
||||
DispatchQueue.main.async {
|
||||
|
@ -150,10 +152,8 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
|
|||
|
||||
func update(_ feed: Feed, with parsedFeed: ParsedFeed, _ completion: @escaping RSVoidCompletionBlock) {
|
||||
|
||||
if feed.takeSettings(from: parsedFeed) {
|
||||
dirty = true
|
||||
}
|
||||
|
||||
feed.takeSettings(from: parsedFeed)
|
||||
|
||||
database.update(feed: feed, parsedFeed: parsedFeed) { (newArticles, updatedArticles) in
|
||||
|
||||
var userInfo = [String: Any]()
|
||||
|
@ -400,6 +400,13 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
|
|||
updateUnreadCount()
|
||||
}
|
||||
|
||||
@objc func feedSettingDidChange(_ note: Notification) {
|
||||
|
||||
if let feed = note.object as? Feed, let feedAccount = feed.account, feedAccount === self {
|
||||
dirty = true
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Equatable
|
||||
|
||||
public class func ==(lhs: Account, rhs: Account) -> Bool {
|
||||
|
|
|
@ -10,6 +10,11 @@ import Foundation
|
|||
import Data
|
||||
import RSParser
|
||||
|
||||
public extension Notification.Name {
|
||||
|
||||
public static let FeedSettingDidChange = Notification.Name(rawValue: "FeedSettingDidChangeNotification")
|
||||
}
|
||||
|
||||
public extension Feed {
|
||||
|
||||
public var account: Account? {
|
||||
|
@ -27,9 +32,7 @@ public extension Feed {
|
|||
return account.fetchArticles(for: self)
|
||||
}
|
||||
|
||||
public func takeSettings(from parsedFeed: ParsedFeed) -> Bool {
|
||||
|
||||
// Return true if anything changed.
|
||||
public func takeSettings(from parsedFeed: ParsedFeed) {
|
||||
|
||||
var didChangeAtLeastOneSetting = false
|
||||
|
||||
|
@ -50,7 +53,9 @@ public extension Feed {
|
|||
didChangeAtLeastOneSetting = true
|
||||
}
|
||||
|
||||
return didChangeAtLeastOneSetting
|
||||
if didChangeAtLeastOneSetting {
|
||||
NotificationCenter.default.post(name: .FeedSettingDidChange, object: self)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue