mirror of
https://github.com/tappollo/IGListKit.git
synced 2026-04-27 17:35:01 +08:00
Drop section moves if they are also deleted or inserted
Summary: Issue fixed: #430 - [x] All tests pass. Demo project builds and runs. - [x] I added tests, an experiment, or detailed why my change isn't tested. - [x] I added an entry to the `CHANGELOG.md` for any breaking changes, enhancements, or bug fixes. Closes https://github.com/Instagram/IGListKit/pull/577 Differential Revision: D4768612 Pulled By: rnystrom fbshipit-source-id: 6a2024101411302446cc2b7843fa175cd43a1562
This commit is contained in:
committed by
Facebook Github Bot
parent
653a5b62da
commit
5eca718ea7
@@ -88,6 +88,8 @@ This release closes the [3.0.0 milestone](https://github.com/Instagram/IGListKit
|
||||
|
||||
- Remove objects that return `nil` diff identifiers before updating. [Ryan Nystrom](https://github.com/rnystrom) [(af984ca)](https://github.com/Instagram/IGListKit/commit/af984ca81d4d8c4ba3012be1a45f69670a832ccf)
|
||||
|
||||
- Fix a potential crash when a section is moved and deleted at the same time. [Ryan Nystrom](https://github.com/rnystrom) [(#577)](https://github.com/Instagram/IGListKit/pull/577)
|
||||
|
||||
2.1.0
|
||||
-----
|
||||
|
||||
|
||||
@@ -77,9 +77,10 @@ static void convertMoveToDeleteAndInsert(NSMutableSet<IGListMoveIndex *> *moves,
|
||||
const NSInteger from = move.from;
|
||||
const NSInteger to = move.to;
|
||||
|
||||
// if the move is already deleted or inserted, discard it and use delete+insert instead
|
||||
// if the move is already deleted or inserted, discard it because count-changing operations must match
|
||||
// with data source changes
|
||||
if ([deleteSections containsIndex:from] || [insertSections containsIndex:to]) {
|
||||
convertMoveToDeleteAndInsert(mMoveSections, move, mDeleteSections, mInsertSections);
|
||||
[mMoveSections removeObject:move];
|
||||
} else {
|
||||
fromMap[from] = move;
|
||||
toMap[to] = move;
|
||||
|
||||
@@ -119,4 +119,18 @@ static IGListMoveIndex *newMove(NSInteger from, NSInteger to) {
|
||||
XCTAssertEqualObjects(result.insertSections, indexSet(@[@1]));
|
||||
}
|
||||
|
||||
- (void)test_whenMovingSections_withMoveFromConflictWithDelete_thatResultDropsTheMove {
|
||||
IGListBatchUpdateData *result = [[IGListBatchUpdateData alloc] initWithInsertSections:indexSet(@[])
|
||||
deleteSections:indexSet(@[@2])
|
||||
moveSections:[NSSet setWithArray:@[newMove(2, 6), newMove(0, 2)]]
|
||||
insertIndexPaths:[NSSet new]
|
||||
deleteIndexPaths:[NSSet new]
|
||||
moveIndexPaths:[NSSet new]];
|
||||
XCTAssertEqual(result.deleteSections.count, 1);
|
||||
XCTAssertEqual(result.moveSections.count, 1);
|
||||
XCTAssertEqual(result.insertSections.count, 0);
|
||||
XCTAssertEqualObjects(result.deleteSections, indexSet(@[@2]));
|
||||
XCTAssertEqualObjects(result.moveSections.anyObject, newMove(0, 2));
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user