hot fix
This commit is contained in:
parent
b2d7f5a0ab
commit
c67ad2c536
@ -188,10 +188,8 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol
|
|||||||
|
|
||||||
open func newData(for molecule: MoleculeModelProtocol) {
|
open func newData(for molecule: MoleculeModelProtocol) {
|
||||||
//TODO: expand for header, navigation, etc
|
//TODO: expand for header, navigation, etc
|
||||||
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
|
if equal(moleculeA: molecule, moleculeB: moleculeInfo.molecule) {
|
||||||
if json == moleculeInfo.molecule.toJSON() {
|
|
||||||
return true
|
return true
|
||||||
} else if let parent = moleculeInfo.molecule as? ParentMoleculeModelProtocol {
|
} else if let parent = moleculeInfo.molecule as? ParentMoleculeModelProtocol {
|
||||||
// Get all molecules of the same type for faster check.
|
// Get all molecules of the same type for faster check.
|
||||||
@ -201,8 +199,8 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol
|
|||||||
}
|
}
|
||||||
return accumulator
|
return accumulator
|
||||||
}
|
}
|
||||||
for molecule in molecules {
|
for moleculeB in molecules {
|
||||||
if json == molecule.toJSON() {
|
if equal(moleculeA: molecule, moleculeB: moleculeB) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -283,6 +281,18 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol
|
|||||||
|
|
||||||
return modules
|
return modules
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Checks if the two molecules are equal
|
||||||
|
private func equal(moleculeA: MoleculeModelProtocol, moleculeB: MoleculeModelProtocol) -> Bool {
|
||||||
|
// TODO: move this to a better approach, maybe a UUID for each model.
|
||||||
|
// Do instance check
|
||||||
|
if let classMoleculeA = moleculeA as? NSObjectProtocol,
|
||||||
|
let classMoleculeB = moleculeB as? NSObjectProtocol {
|
||||||
|
return classMoleculeA === classMoleculeB
|
||||||
|
}
|
||||||
|
// Do json check
|
||||||
|
return moleculeA.toJSON() == moleculeB.toJSON()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension MoleculeListTemplate: MoleculeListProtocol {
|
extension MoleculeListTemplate: MoleculeListProtocol {
|
||||||
@ -320,9 +330,7 @@ extension MoleculeListTemplate: MoleculeListProtocol {
|
|||||||
|
|
||||||
open func getIndexPath(for molecule: ListItemModelProtocol & MoleculeModelProtocol) -> IndexPath? {
|
open func getIndexPath(for molecule: ListItemModelProtocol & MoleculeModelProtocol) -> IndexPath? {
|
||||||
guard let index = moleculesInfo?.firstIndex(where: { (moleculeInfo) -> Bool in
|
guard let index = moleculesInfo?.firstIndex(where: { (moleculeInfo) -> Bool in
|
||||||
//TODO: check for molecule protocol eqaulity
|
return equal(moleculeA: molecule, moleculeB: moleculeInfo.molecule)
|
||||||
let json = moleculeInfo.molecule.toJSON()
|
|
||||||
return json == molecule.toJSON()
|
|
||||||
}) else { return nil }
|
}) else { return nil }
|
||||||
|
|
||||||
return IndexPath(row: index, section: 0)
|
return IndexPath(row: index, section: 0)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user