From 52b468ec40fbfc4ca0176d63d4cc39c80f641fd6 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Fri, 23 Feb 2018 22:17:48 +0100 Subject: [PATCH] Speedup the display of a chatroom. On a relatively long, the time for loading the chatroom view decreases from 21 seconds to 7 seconds. The main problem is that each the view is entered [tableView reloadData] was called three times. --- Classes/ChatConversationView.h | 1 + Classes/ChatConversationView.m | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Classes/ChatConversationView.h b/Classes/ChatConversationView.h index 58eee2358..1ff2e48ab 100644 --- a/Classes/ChatConversationView.h +++ b/Classes/ChatConversationView.h @@ -36,6 +36,7 @@ OrderedDictionary *imageQualities; BOOL scrollOnGrowingEnabled; BOOL composingVisible; + BOOL isAppearing; } @property(nonatomic) LinphoneChatRoom *chatRoom; diff --git a/Classes/ChatConversationView.m b/Classes/ChatConversationView.m index 8bfc855fc..35d25c21c 100644 --- a/Classes/ChatConversationView.m +++ b/Classes/ChatConversationView.m @@ -37,6 +37,7 @@ [NSNumber numberWithFloat:0.5], NSLocalizedString(@"Average", nil), [NSNumber numberWithFloat:0.0], NSLocalizedString(@"Minimum", nil), nil]; composingVisible = false; + isAppearing = false; } return self; } @@ -109,6 +110,7 @@ static UICompositeViewDescription *compositeDescription = nil; name:kLinphoneCallUpdate object:nil]; [self configureForRoom:false]; + isAppearing = true; } - (void)viewWillDisappear:(BOOL)animated { @@ -131,10 +133,12 @@ static UICompositeViewDescription *compositeDescription = nil; [NSNotificationCenter.defaultCenter removeObserver:self]; PhoneMainView.instance.currentRoom = NULL; + isAppearing = FALSE; } - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation { [super didRotateFromInterfaceOrientation:fromInterfaceOrientation]; + if (!isAppearing) return; //no need to do all that stuff if the view isn't yet appeared. // force offset recomputing [_messageField refreshHeight]; [self configureForRoom:true]; @@ -168,7 +172,7 @@ static UICompositeViewDescription *compositeDescription = nil; if (_tableController.isEditing) [_tableController setEditing:editing]; - [[_tableController tableView] reloadData]; + //[[_tableController tableView] reloadData]; BOOL fileSharingEnabled = linphone_core_get_file_transfer_server(LC) != NULL; [_pictureButton setEnabled:fileSharingEnabled];