From 43dc9b0d8d9e34c9ab599dea7dab5724c90d690c Mon Sep 17 00:00:00 2001 From: Morgan Chen Date: Wed, 29 May 2019 13:38:41 -0700 Subject: [PATCH] Reload table view cells after move --- .../FUIFirestoreTableViewDataSource.m | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Firestore/FirebaseFirestoreUI/FUIFirestoreTableViewDataSource.m b/Firestore/FirebaseFirestoreUI/FUIFirestoreTableViewDataSource.m index 6048f467719..0ceee978a59 100644 --- a/Firestore/FirebaseFirestoreUI/FUIFirestoreTableViewDataSource.m +++ b/Firestore/FirebaseFirestoreUI/FUIFirestoreTableViewDataSource.m @@ -130,6 +130,16 @@ - (void)batchedArray:(FUIBatchedArray *)array withRowAnimation:self.animation]; [self.tableView endUpdates]; + + // Reload paths that have been moved. + NSMutableArray *movedIndexPaths = + [NSMutableArray arrayWithCapacity:diff.movedResultIndexes.count]; + for (NSNumber *movedResultIndex in diff.movedResultIndexes) { + NSIndexPath *moved = [NSIndexPath indexPathForItem:movedResultIndex.integerValue inSection:0]; + [movedIndexPaths addObject:moved]; + } + [self.tableView reloadRowsAtIndexPaths:movedIndexPaths + withRowAnimation:UITableViewRowAnimationAutomatic]; } - (void)batchedArray:(FUIBatchedArray *)array queryDidFailWithError:(NSError *)error {