Handle feed renames in the inspector. Handle multiple selection. Fix #137.

This commit is contained in:
Brent Simmons
2018-01-23 21:49:33 -08:00
parent aa32b09d2d
commit f109237bfa
6 changed files with 79 additions and 12 deletions

View File

@@ -129,12 +129,11 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
self.database = Database(databaseFilePath: databaseFilePath, accountID: accountID)
NotificationCenter.default.addObserver(self, selector: #selector(downloadProgressDidChange(_:)), name: .DownloadProgressDidChange, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(unreadCountDidChange(_:)), name: .UnreadCountDidChange, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(batchUpdateDidPerform(_:)), name: .BatchUpdateDidPerform, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(batchUpdateDidPerform(_:)), name: .BatchUpdateDidPerform, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(feedSettingDidChange(_:)), name: .FeedSettingDidChange, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(displayNameDidChange(_:)), name: .DisplayNameDidChange, object: nil)
pullObjectsFromDisk()
@@ -438,6 +437,16 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
}
}
@objc func displayNameDidChange(_ note: Notification) {
if let feed = note.object as? Feed, let feedAccount = feed.account, feedAccount === self {
dirty = true
}
if let folder = note.object as? Folder, let folderAccount = folder.account, folderAccount === self {
dirty = true
}
}
// MARK: - Equatable
public class func ==(lhs: Account, rhs: Account) -> Bool {

View File

@@ -17,7 +17,6 @@ public final class Folder: DisplayNameProvider, Container, UnreadCountProvider,
public var name: String? {
didSet {
account?.dirty = true
postDisplayNameDidChangeNotification()
}
}

View File

@@ -20,7 +20,13 @@ public final class Feed: DisplayNameProvider, UnreadCountProvider, Hashable {
public var faviconURL: String?
public var name: String?
public var authors: Set<Author>?
public var editedName: String?
public var editedName: String? {
didSet {
postDisplayNameDidChangeNotification()
}
}
public var conditionalGetInfo: HTTPConditionalGetInfo?
public var contentHash: String?
public let hashValue: Int
@@ -29,7 +35,13 @@ public final class Feed: DisplayNameProvider, UnreadCountProvider, Hashable {
public var nameForDisplay: String {
get {
return (editedName ?? name) ?? NSLocalizedString("Untitled", comment: "Feed name")
if let s = editedName, !s.isEmpty {
return s
}
if let s = name, !s.isEmpty {
return s
}
return NSLocalizedString("Untitled", comment: "Feed name")
}
}