fixes
This commit is contained in:
parent
350edf147c
commit
f0c567d6d4
@ -183,10 +183,8 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol
|
||||
//--------------------------------------------------
|
||||
|
||||
open override func moleculeLayoutUpdated(_ molecule: MoleculeViewProtocol) {
|
||||
guard let tableView = tableView else { return }
|
||||
|
||||
let point = molecule.convert(molecule.center, to: tableView)
|
||||
if let indexPath = tableView.indexPathForRow(at: point), tableView.indexPathsForVisibleRows?.contains(indexPath) ?? false {
|
||||
guard let tableView = tableView else { return }
|
||||
if let indexPath = tableView.indexPathForRow(at: molecule.center), tableView.indexPathsForVisibleRows?.contains(indexPath) ?? false {
|
||||
performTableViewUpdates()
|
||||
}
|
||||
}
|
||||
@ -226,25 +224,27 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol
|
||||
//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() {
|
||||
//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
|
||||
return false
|
||||
}) else { return }
|
||||
|
||||
// Refresh the cell.
|
||||
let indexPath = IndexPath(row: index, section: 0)
|
||||
tableView.reloadRows(at: [indexPath], with: .none)
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user