Digital PCT265 story PCT-135: Prevent registering table cells on ListViewTemplate handleNewData when the page is not changing.
This commit is contained in:
parent
eac64ec506
commit
52e8ce7621
@ -19,7 +19,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol
|
|||||||
public var moleculesInfo: [MoleculeInfo]?
|
public var moleculesInfo: [MoleculeInfo]?
|
||||||
|
|
||||||
var observer: NSKeyValueObservation?
|
var observer: NSKeyValueObservation?
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Computed Properties
|
// MARK: - Computed Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -87,8 +87,11 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol
|
|||||||
|
|
||||||
open override func handleNewData(_ pageModel: PageModelProtocol? = nil) {
|
open override func handleNewData(_ pageModel: PageModelProtocol? = nil) {
|
||||||
super.handleNewData(pageModel)
|
super.handleNewData(pageModel)
|
||||||
setup()
|
|
||||||
registerWithTable()
|
if pageModel != nil {
|
||||||
|
setup()
|
||||||
|
registerWithTable()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
open override func updateUI(for molecules: [MoleculeModelProtocol]? = nil) {
|
open override func updateUI(for molecules: [MoleculeModelProtocol]? = nil) {
|
||||||
@ -368,7 +371,7 @@ extension MoleculeListTemplate: MoleculeListProtocol {
|
|||||||
let removeIndex = indexPath.row - index
|
let removeIndex = indexPath.row - index
|
||||||
moleculesInfo?.remove(at: removeIndex)
|
moleculesInfo?.remove(at: removeIndex)
|
||||||
}
|
}
|
||||||
|
|
||||||
guard let animation = animation,
|
guard let animation = animation,
|
||||||
indexPaths.count > 0 else { return }
|
indexPaths.count > 0 else { return }
|
||||||
tableView?.deleteRows(at: indexPaths, with: animation)
|
tableView?.deleteRows(at: indexPaths, with: animation)
|
||||||
@ -378,7 +381,7 @@ extension MoleculeListTemplate: MoleculeListProtocol {
|
|||||||
|
|
||||||
public func addMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], indexPath: IndexPath, animation: UITableView.RowAnimation?) {
|
public func addMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], indexPath: IndexPath, animation: UITableView.RowAnimation?) {
|
||||||
var indexPaths: [IndexPath] = []
|
var indexPaths: [IndexPath] = []
|
||||||
|
|
||||||
for molecule in molecules {
|
for molecule in molecules {
|
||||||
if let info = self.createMoleculeInfo(with: molecule) {
|
if let info = self.createMoleculeInfo(with: molecule) {
|
||||||
self.tableView?.register(info.class, forCellReuseIdentifier: info.identifier)
|
self.tableView?.register(info.class, forCellReuseIdentifier: info.identifier)
|
||||||
@ -387,7 +390,7 @@ extension MoleculeListTemplate: MoleculeListProtocol {
|
|||||||
indexPaths.append(IndexPath(row: index, section: 0))
|
indexPaths.append(IndexPath(row: index, section: 0))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
guard let animation = animation,
|
guard let animation = animation,
|
||||||
indexPaths.count > 0 else { return }
|
indexPaths.count > 0 else { return }
|
||||||
self.tableView?.insertRows(at: indexPaths, with: animation)
|
self.tableView?.insertRows(at: indexPaths, with: animation)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user