vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewChange.m in motion-yapper-0.0.1 vs vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewChange.m in motion-yapper-0.0.2

- old
+ new

@@ -367,12 +367,13 @@ // the the drawing of cells has an dependency upon neighboring cells. NSMutableArray *sectionChanges = [NSMutableArray arrayWithCapacity:1]; NSMutableArray *rowChanges = [NSMutableArray arrayWithCapacity:[changes count]]; - NSSet *groups = [NSSet setWithArray:[originalMappings allGroups]]; - + NSSet *originalGroups = [NSSet setWithArray:[originalMappings allGroups]]; + NSSet *finalGroups = [NSSet setWithArray:[finalMappings allGroups]]; + NSMutableDictionary *counts = [originalMappings counts]; NSDictionary *dependencies = [originalMappings dependencies]; for (id change in changes) { @@ -381,11 +382,11 @@ __unsafe_unretained YapDatabaseViewSectionChange *immutableSectionChange = (YapDatabaseViewSectionChange *)change; if (immutableSectionChange->type == YapDatabaseViewChangeDelete) { - if ([groups containsObject:immutableSectionChange->group]) + if ([originalGroups containsObject:immutableSectionChange->group]) { YapDatabaseViewSectionChange *sectionChange = [immutableSectionChange copy]; [sectionChanges addObject:sectionChange]; if (sectionChange->isReset) @@ -447,11 +448,11 @@ } } } else if (immutableSectionChange->type == YapDatabaseViewChangeInsert) { - if ([groups containsObject:immutableSectionChange->group]) + if ([finalGroups containsObject:immutableSectionChange->group]) { YapDatabaseViewSectionChange *sectionChange = [immutableSectionChange copy]; [sectionChanges addObject:sectionChange]; } } @@ -462,14 +463,14 @@ __unsafe_unretained NSString *group = nil; NSUInteger groupCount = 0; NSUInteger groupIndex = 0; BOOL wasDelete = 0; - + if (immutableRowChange->type == YapDatabaseViewChangeDelete) { - if ([groups containsObject:immutableRowChange->originalGroup]) + if ([originalGroups containsObject:immutableRowChange->originalGroup]) { YapDatabaseViewRowChange *rowChange = [immutableRowChange copy]; [rowChanges addObject:rowChange]; group = rowChange->originalGroup; @@ -482,11 +483,11 @@ wasDelete = YES; } } else if (immutableRowChange->type == YapDatabaseViewChangeInsert) { - if ([groups containsObject:immutableRowChange->finalGroup]) + if ([finalGroups containsObject:immutableRowChange->finalGroup]) { YapDatabaseViewRowChange *rowChange = [immutableRowChange copy]; [rowChanges addObject:rowChange]; group = rowChange->finalGroup; @@ -497,11 +498,11 @@ [counts setObject:@(groupCount) forKey:group]; } } else if (immutableRowChange->type == YapDatabaseViewChangeUpdate) { - if ([groups containsObject:immutableRowChange->originalGroup]) + if ([finalGroups containsObject:immutableRowChange->originalGroup]) { YapDatabaseViewRowChange *rowChange = [immutableRowChange copy]; [rowChanges addObject:rowChange]; group = rowChange->originalGroup; @@ -811,10 +812,11 @@ // and may ultimately update the wrong cell. firstChangeForKey->type = YapDatabaseViewChangeMove; firstChangeForKey->finalIndex = lastChangeForKey->finalIndex; firstChangeForKey->finalGroup = lastChangeForKey->finalGroup; + firstChangeForKey->opFinalIndex = lastChangeForKey->opFinalIndex; // for postProcessing [changes removeObjectsAtIndexes:indexSet]; i++; } else if (lastChangeForKey->type == YapDatabaseViewChangeUpdate) @@ -831,10 +833,11 @@ // and may ultimately update the wrong cell. firstChangeForKey->type = YapDatabaseViewChangeMove; firstChangeForKey->finalIndex = lastChangeForKey->finalIndex; firstChangeForKey->finalGroup = lastChangeForKey->finalGroup; + firstChangeForKey->opFinalIndex = lastChangeForKey->opFinalIndex; // for postProcessing [changes removeObjectsAtIndexes:indexSet]; i++; } } @@ -846,11 +849,10 @@ // // All operations are no-ops (& i remains the same) [changes removeObjectsAtIndexes:indexSet]; [changes removeObjectAtIndex:i]; - } else if (lastChangeForKey->type == YapDatabaseViewChangeInsert) { // Insert + Delete + ... + Insert // @@ -899,14 +901,17 @@ // // If we attempt to consolidate this into an update, // then the tableView/collectionView will offset the update's index // based on insertions & deletions at smaller indexes, // and may ultimately update the wrong cell. + // + // The final location comes from the last update firstChangeForKey->type = YapDatabaseViewChangeMove; firstChangeForKey->finalIndex = lastChangeForKey->finalIndex; firstChangeForKey->finalGroup = lastChangeForKey->finalGroup; + firstChangeForKey->opFinalIndex = lastChangeForKey->opFinalIndex; // for postProcessing [changes removeObjectsAtIndexes:indexSet]; i++; } else // if (lastChangeForKey->type == YapDatabaseViewChangeUpdate) @@ -945,9 +950,10 @@ // The final location comes from the last update firstChangeForKey->type = YapDatabaseViewChangeMove; firstChangeForKey->finalIndex = lastChangeForKey->finalIndex; firstChangeForKey->finalGroup = lastChangeForKey->finalGroup; + firstChangeForKey->opFinalIndex = lastChangeForKey->opFinalIndex; // for postProcessing [changes removeObjectsAtIndexes:indexSet]; i++; } }