[ios] Immediately remove offline pack from table

Remove all references to an offline pack before the call to -removePackWithCompletionHander:.

Cherry-picked from d64b8ad25c.
This commit is contained in:
Minh Nguyễn
2016-03-12 15:08:34 -08:00
committed by Minh Nguyễn
parent ac54129060
commit 922269cd7c

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];
}
}