diff --git a/MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift b/MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift index ad908568..ef382c0f 100644 --- a/MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift +++ b/MVMCoreUI/Atomic/Templates/MoleculeListTemplate.swift @@ -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)