[ios] Immediately remove offline pack from table

Remove all references to an offline pack before the call to -removePackWithCompletionHander:.
This commit is contained in:
Minh Nguyễn
2016-03-12 15:08:34 -08:00
committed by Minh Nguyễn
parent f6c21a0efe
commit d64b8ad25c

View File

@@ -164,12 +164,9 @@ static NSString * const MBXOfflinePacksTableViewActiveCellReuseIdentifier = @"Ac
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) {
MGLOfflinePack *pack = self.offlinePacks[indexPath.row];
__weak MBXOfflinePacksTableViewController *weakSelf = self;
[[MGLOfflineStorage sharedOfflineStorage] removePack:pack withCompletionHandler:^(NSError *error) {
MBXOfflinePacksTableViewController *strongSelf = weakSelf;
[strongSelf.offlinePacks removeObjectAtIndex:indexPath.row];
[strongSelf.tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
}];
[self.offlinePacks removeObjectAtIndex:indexPath.row];
[self.tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
[[MGLOfflineStorage sharedOfflineStorage] removePack:pack withCompletionHandler:nil];
}
}