update view for given molecule
This commit is contained in:
parent
d00897cf75
commit
350edf147c
@ -222,6 +222,33 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
open func newData(for molecule: MoleculeModelProtocol) {
|
||||||
|
//TODO: expand for header, navigation, etc
|
||||||
|
let json = molecule.toJSON()
|
||||||
|
guard let index = moleculesInfo?.firstIndex(where: { (moleculeInfo) -> Bool in
|
||||||
|
//TODO: check for molecule protocol eqaulity
|
||||||
|
if json == moleculeInfo.molecule.toJSON() {
|
||||||
|
return true
|
||||||
|
} else if let parent = moleculeInfo.molecule as? ParentMoleculeModelProtocol {
|
||||||
|
// Get all molecules of the same type for faster check.
|
||||||
|
let molecules: [MoleculeModelProtocol] = parent.reduceDepthFirstTraverse(options: .childFirst, depth: 0, initialResult: []) { (accumulator, currentMolecule, depth) in
|
||||||
|
if currentMolecule.moleculeName == molecule.moleculeName {
|
||||||
|
return accumulator + [currentMolecule]
|
||||||
|
}
|
||||||
|
return accumulator
|
||||||
|
}
|
||||||
|
for molecule in molecules {
|
||||||
|
if json == molecule.toJSON() {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}) else { return }
|
||||||
|
let indexPath = IndexPath(row: index, section: 0)
|
||||||
|
tableView.reloadRows(at: [indexPath], with: .none)
|
||||||
|
}
|
||||||
|
|
||||||
open override func removeMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], animation: UITableView.RowAnimation) {
|
open override func removeMolecules(_ molecules: [ListItemModelProtocol & MoleculeModelProtocol], animation: UITableView.RowAnimation) {
|
||||||
var indexPaths: [IndexPath] = []
|
var indexPaths: [IndexPath] = []
|
||||||
//TODO: check for molecule protocol equality
|
//TODO: check for molecule protocol equality
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user