fixes
This commit is contained in:
parent
350edf147c
commit
f0c567d6d4
@ -184,9 +184,7 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol
|
|||||||
|
|
||||||
open override func moleculeLayoutUpdated(_ molecule: MoleculeViewProtocol) {
|
open override func moleculeLayoutUpdated(_ molecule: MoleculeViewProtocol) {
|
||||||
guard let tableView = tableView else { return }
|
guard let tableView = tableView else { return }
|
||||||
|
if let indexPath = tableView.indexPathForRow(at: molecule.center), tableView.indexPathsForVisibleRows?.contains(indexPath) ?? false {
|
||||||
let point = molecule.convert(molecule.center, to: tableView)
|
|
||||||
if let indexPath = tableView.indexPathForRow(at: point), tableView.indexPathsForVisibleRows?.contains(indexPath) ?? false {
|
|
||||||
performTableViewUpdates()
|
performTableViewUpdates()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -226,25 +224,27 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol
|
|||||||
//TODO: expand for header, navigation, etc
|
//TODO: expand for header, navigation, etc
|
||||||
let json = molecule.toJSON()
|
let json = molecule.toJSON()
|
||||||
guard let index = moleculesInfo?.firstIndex(where: { (moleculeInfo) -> Bool in
|
guard let index = moleculesInfo?.firstIndex(where: { (moleculeInfo) -> Bool in
|
||||||
//TODO: check for molecule protocol eqaulity
|
//TODO: check for molecule protocol eqaulity
|
||||||
if json == moleculeInfo.molecule.toJSON() {
|
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 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 }
|
}) else { return }
|
||||||
|
|
||||||
|
// Refresh the cell.
|
||||||
let indexPath = IndexPath(row: index, section: 0)
|
let indexPath = IndexPath(row: index, section: 0)
|
||||||
tableView.reloadRows(at: [indexPath], with: .none)
|
tableView.reloadRows(at: [indexPath], with: .none)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user