diff --git a/Classes/ChatConversationTableView.h b/Classes/ChatConversationTableView.h index b603ab3f4..dc0e4c574 100644 --- a/Classes/ChatConversationTableView.h +++ b/Classes/ChatConversationTableView.h @@ -39,6 +39,7 @@ @private NSMutableArray *eventList; NSMutableArray *totalEventList; + BOOL preLoad; } @property(nonatomic) LinphoneChatRoom *chatRoom; diff --git a/Classes/ChatConversationTableView.m b/Classes/ChatConversationTableView.m index babff47e6..80e7af912 100644 --- a/Classes/ChatConversationTableView.m +++ b/Classes/ChatConversationTableView.m @@ -105,7 +105,9 @@ - (void)reloadData { [self updateData]; + preLoad = TRUE; [self.tableView reloadData]; + preLoad = FALSE; [self scrollToLastUnread:false]; } @@ -295,6 +297,9 @@ static const int BASIC_EVENT_LIST=20; static const CGFloat MESSAGE_SPACING_PERCENTAGE = 1.f; - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { + // pre-download data + if (preLoad) + return 0; LinphoneEventLog *event = [[eventList objectAtIndex:indexPath.row] pointerValue]; if (linphone_event_log_get_type(event) == LinphoneEventLogTypeConferenceChatMessage) { LinphoneChatMessage *chat = linphone_event_log_get_chat_message(event); diff --git a/Classes/LinphoneUI/UIChatBubbleTextCell.m b/Classes/LinphoneUI/UIChatBubbleTextCell.m index 87fa8beb0..83da201c6 100644 --- a/Classes/LinphoneUI/UIChatBubbleTextCell.m +++ b/Classes/LinphoneUI/UIChatBubbleTextCell.m @@ -421,9 +421,10 @@ static const CGFloat CELL_IMAGE_X_MARGIN = 100; + (CGSize)ViewHeightForMessageText:(LinphoneChatMessage *)chat withWidth:(int)width textForImdn:(NSString *)imdnText{ - // avoid calculating the size each time + // Avoid calculating the size each time, it takes too much time. Update the size of the chat cell once the version of the application has been modified. NSString *chatSize = [LinphoneManager getMessageAppDataForKey:@"newChatSize" inMessage:chat]; - if (chatSize && !imdnText) + NSString *version = [NSString stringWithFormat:@"%@-%@",[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"],[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"]]; + if (chatSize && !imdnText && [version isEqualToString:[LinphoneManager getMessageAppDataForKey:@"appVersion" inMessage:chat]]) return CGSizeFromString(chatSize); NSString *messageText = [UIChatBubbleTextCell TextMessageForChat:chat]; @@ -510,6 +511,7 @@ static const CGFloat CELL_IMAGE_X_MARGIN = 100; size.height = MAX(size.height + CELL_MESSAGE_Y_MARGIN, CELL_MIN_HEIGHT); [LinphoneManager setValueInMessageAppData:NSStringFromCGSize(size) forKey:@"newChatSize" inMessage:chat]; + [LinphoneManager setValueInMessageAppData:version forKey:@"appVersion" inMessage:chat]; return size; }