From 202e33a736da5524c4a6d9c804171c56096feb24 Mon Sep 17 00:00:00 2001 From: Danmei Chen Date: Wed, 6 Mar 2019 16:54:45 +0100 Subject: [PATCH] fix delete chat cells --- Classes/ChatConversationTableView.m | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Classes/ChatConversationTableView.m b/Classes/ChatConversationTableView.m index a981f3b13..71efb2925 100644 --- a/Classes/ChatConversationTableView.m +++ b/Classes/ChatConversationTableView.m @@ -40,6 +40,7 @@ [super viewWillAppear:animated]; self.tableView.accessibilityIdentifier = @"ChatRoom list"; _imagesInChatroom = [NSMutableDictionary dictionary]; + _currentIndex = 0; } #pragma mark - @@ -317,10 +318,10 @@ static const CGFloat MESSAGE_SPACING_PERCENTAGE = 1.f; [tableView beginUpdates]; LinphoneEventLog *event = [[eventList objectAtIndex:indexPath.row] pointerValue]; linphone_event_log_delete_from_database(event); + NSInteger index = indexPath.row + _currentIndex + (totalEventList.count - eventList.count); + if (index < totalEventList.count) + [totalEventList removeObjectAtIndex:index]; [eventList removeObjectAtIndex:indexPath.row]; - NSInteger index = indexPath.row + _currentIndex + (totalEventList.count - eventList.count); - if (index < totalEventList.count) - [totalEventList removeObjectAtIndex:index]; [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationBottom]; @@ -365,10 +366,10 @@ static const CGFloat MESSAGE_SPACING_PERCENTAGE = 1.f; [super removeSelectionUsing:^(NSIndexPath *indexPath) { LinphoneEventLog *event = [[eventList objectAtIndex:indexPath.row] pointerValue]; linphone_event_log_delete_from_database(event); - [eventList removeObjectAtIndex:indexPath.row]; NSInteger index = indexPath.row + _currentIndex + (totalEventList.count - eventList.count); if (index < totalEventList.count) [totalEventList removeObjectAtIndex:index]; + [eventList removeObjectAtIndex:indexPath.row]; }]; }