Force unread count updates to reload cells as they can change the height of cells now by reflowing the name
This commit is contained in:
parent
95430913bd
commit
38a3cde8a6
@ -70,6 +70,8 @@ class MasterFeedViewController: ProgressTableViewController, UndoableCommandRunn
|
|||||||
|
|
||||||
@objc func unreadCountDidChange(_ note: Notification) {
|
@objc func unreadCountDidChange(_ note: Notification) {
|
||||||
|
|
||||||
|
updateUI()
|
||||||
|
|
||||||
guard let representedObject = note.object else {
|
guard let representedObject = note.object else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -84,8 +86,12 @@ class MasterFeedViewController: ProgressTableViewController, UndoableCommandRunn
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
configureUnreadCountForCellsForRepresentedObject(representedObject as AnyObject)
|
guard let node = navState.rootNode.childNodeRepresentingObject(representedObject as AnyObject),
|
||||||
updateUI()
|
let indexPath = navState.indexPathFor(node) else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
tableView.reloadRows(at: [indexPath], with: .automatic)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,16 +171,6 @@ class MasterFeedViewController: ProgressTableViewController, UndoableCommandRunn
|
|||||||
let headerView = MasterFeedTableViewSectionHeader()
|
let headerView = MasterFeedTableViewSectionHeader()
|
||||||
headerView.name = nameProvider.nameForDisplay
|
headerView.name = nameProvider.nameForDisplay
|
||||||
|
|
||||||
guard let sectionNode = navState.rootNode.childAtIndex(section) else {
|
|
||||||
return 44
|
|
||||||
}
|
|
||||||
|
|
||||||
if let account = sectionNode.representedObject as? Account {
|
|
||||||
headerView.unreadCount = account.unreadCount
|
|
||||||
} else {
|
|
||||||
headerView.unreadCount = 0
|
|
||||||
}
|
|
||||||
|
|
||||||
let size = headerView.sizeThatFits(CGSize(width: tableView.bounds.width, height: 0.0))
|
let size = headerView.sizeThatFits(CGSize(width: tableView.bounds.width, height: 0.0))
|
||||||
return size.height
|
return size.height
|
||||||
|
|
||||||
@ -470,16 +466,12 @@ class MasterFeedViewController: ProgressTableViewController, UndoableCommandRunn
|
|||||||
cell.allowDisclosureSelection = node.canHaveChildNodes
|
cell.allowDisclosureSelection = node.canHaveChildNodes
|
||||||
|
|
||||||
cell.name = nameFor(node)
|
cell.name = nameFor(node)
|
||||||
configureUnreadCount(cell, node)
|
cell.unreadCount = unreadCountFor(node)
|
||||||
configureFavicon(cell, node)
|
configureFavicon(cell, node)
|
||||||
cell.shouldShowImage = node.representedObject is SmallIconProvider
|
cell.shouldShowImage = node.representedObject is SmallIconProvider
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func configureUnreadCount(_ cell: MasterFeedTableViewCell, _ node: Node) {
|
|
||||||
cell.unreadCount = unreadCountFor(node)
|
|
||||||
}
|
|
||||||
|
|
||||||
func configureFavicon(_ cell: MasterFeedTableViewCell, _ node: Node) {
|
func configureFavicon(_ cell: MasterFeedTableViewCell, _ node: Node) {
|
||||||
cell.faviconImage = imageFor(node)
|
cell.faviconImage = imageFor(node)
|
||||||
}
|
}
|
||||||
@ -598,10 +590,6 @@ private extension MasterFeedViewController {
|
|||||||
applyToCellsForRepresentedObject(representedObject, configure)
|
applyToCellsForRepresentedObject(representedObject, configure)
|
||||||
}
|
}
|
||||||
|
|
||||||
func configureUnreadCountForCellsForRepresentedObject(_ representedObject: AnyObject) {
|
|
||||||
applyToCellsForRepresentedObject(representedObject, configureUnreadCount)
|
|
||||||
}
|
|
||||||
|
|
||||||
func applyToCellsForRepresentedObject(_ representedObject: AnyObject, _ callback: (MasterFeedTableViewCell, Node) -> Void) {
|
func applyToCellsForRepresentedObject(_ representedObject: AnyObject, _ callback: (MasterFeedTableViewCell, Node) -> Void) {
|
||||||
applyToAvailableCells { (cell, node) in
|
applyToAvailableCells { (cell, node) in
|
||||||
if node.representedObject === representedObject {
|
if node.representedObject === representedObject {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user