Fix subtitle for scenario where multiple are selected.

This commit is contained in:
Maurice Parker 2020-09-02 13:00:09 -05:00
parent a0d2ee472d
commit 7c7b128380
1 changed files with 32 additions and 17 deletions

View File

@ -1199,30 +1199,45 @@ private extension MainWindowController {
}
func updateWindowTitle() {
var displayName: String? = nil
var unreadCount: Int? = nil
if let displayNameProvider = currentFeedOrFolder as? DisplayNameProvider {
displayName = displayNameProvider.nameForDisplay
}
if let unreadCountProvider = currentFeedOrFolder as? UnreadCountProvider {
unreadCount = unreadCountProvider.unreadCount
}
if displayName != nil {
window?.title = displayName!
func setSubtitle(_ count: Int) {
let localizedLabel = NSLocalizedString("%d unread", comment: "Unread")
let formattedLabel = NSString.localizedStringWithFormat(localizedLabel as NSString, count)
if #available(macOS 11.0, *) {
window?.subtitle = "\(unreadCount ?? 0) unread"
window?.subtitle = formattedLabel as String
}
} else {
}
guard let selectedObjects = selectedObjectsInSidebar(), selectedObjects.count > 0 else {
window?.title = appDelegate.appName!
if #available(macOS 11.0, *) {
window?.subtitle = "\(appDelegate.unreadCount) unread"
setSubtitle(appDelegate.unreadCount)
}
return
}
guard selectedObjects.count == 1 else {
window?.title = NSLocalizedString("Multiple", comment: "Multiple")
if #available(macOS 11.0, *) {
let unreadCount = selectedObjects.reduce(0, { result, selectedObject in
if let unreadCountProvider = selectedObject as? UnreadCountProvider {
return result + unreadCountProvider.unreadCount
} else {
return result
}
})
setSubtitle(unreadCount)
}
return
}
if let displayNameProvider = currentFeedOrFolder as? DisplayNameProvider {
window?.title = displayNameProvider.nameForDisplay
if #available(macOS 11.0, *) {
if let unreadCountProvider = currentFeedOrFolder as? UnreadCountProvider {
setSubtitle(unreadCountProvider.unreadCount)
}
}
}
}
func startArticleExtractorForCurrentLink() {