Digital PCT265 story PCT-135: Prevent registering table cells on ListViewTemplate handleNewData when the page is not changing.

This commit is contained in:
Hedden, Kyle Matthew 2024-05-16 10:20:31 -04:00
parent eac64ec506
commit 52e8ce7621

View File

@ -19,7 +19,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol
public var moleculesInfo: [MoleculeInfo]?
var observer: NSKeyValueObservation?
//--------------------------------------------------
// MARK: - Computed Properties
//--------------------------------------------------
@ -87,8 +87,11 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol
open override func handleNewData(_ pageModel: PageModelProtocol? = nil) {
super.handleNewData(pageModel)
setup()
registerWithTable()
if pageModel != nil {
setup()
registerWithTable()
}
}
open override func updateUI(for molecules: [MoleculeModelProtocol]? = nil) {
@ -368,7 +371,7 @@ extension MoleculeListTemplate: MoleculeListProtocol {
let removeIndex = indexPath.row - index
moleculesInfo?.remove(at: removeIndex)
}
guard let animation = animation,
indexPaths.count > 0 else { return }
tableView?.deleteRows(at: indexPaths, with: animation)
@ -378,7 +381,7 @@ extension MoleculeListTemplate: MoleculeListProtocol {
public func addMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], indexPath: IndexPath, animation: UITableView.RowAnimation?) {
var indexPaths: [IndexPath] = []
for molecule in molecules {
if let info = self.createMoleculeInfo(with: molecule) {
self.tableView?.register(info.class, forCellReuseIdentifier: info.identifier)
@ -387,7 +390,7 @@ extension MoleculeListTemplate: MoleculeListProtocol {
indexPaths.append(IndexPath(row: index, section: 0))
}
}
guard let animation = animation,
indexPaths.count > 0 else { return }
self.tableView?.insertRows(at: indexPaths, with: animation)