From d73a5ff333c08b5c9d08719fe7e551344521c390 Mon Sep 17 00:00:00 2001 From: Danmei Chen Date: Tue, 29 Jun 2021 18:25:57 +0200 Subject: [PATCH] Revert "fix again" This reverts commit c613c76fd183dc98c6db3bb72a283a9bca0bc95f. --- Classes/ChatConversationTableView.m | 8 +---- Classes/LinphoneUI/UIChatBubblePhotoCell.m | 36 ++++++++++------------ Classes/LinphoneUI/UIChatBubbleTextCell.m | 1 + 3 files changed, 19 insertions(+), 26 deletions(-) diff --git a/Classes/ChatConversationTableView.m b/Classes/ChatConversationTableView.m index 8563f39d7..2cb6664fb 100644 --- a/Classes/ChatConversationTableView.m +++ b/Classes/ChatConversationTableView.m @@ -124,14 +124,8 @@ LOGW(@"event entry doesn't exist"); return; } - if (index == (eventList.count-1)) { - [self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:index inSection:0] - atScrollPosition:UITableViewScrollPositionBottom - animated:YES]; - } else { - [self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:[NSIndexPath indexPathForRow:index inSection:0]] + [self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:[NSIndexPath indexPathForRow:index inSection:0]] withRowAnimation:FALSE]; // just reload - } return; } diff --git a/Classes/LinphoneUI/UIChatBubblePhotoCell.m b/Classes/LinphoneUI/UIChatBubblePhotoCell.m index d19d563da..4c8d77b44 100644 --- a/Classes/LinphoneUI/UIChatBubblePhotoCell.m +++ b/Classes/LinphoneUI/UIChatBubblePhotoCell.m @@ -171,32 +171,28 @@ static const CGFloat CELL_IMAGE_X_MARGIN = 100; BOOL is_outgoing = linphone_chat_message_is_outgoing(self.message); if (!is_outgoing) { - if (linphone_chat_message_get_state(self.message) == LinphoneChatMessageStateFileTransferInProgress) { - _cancelButton.hidden = _fileTransferProgress.hidden = NO; - _downloadButton.hidden = YES; - _playButton.hidden = YES; - _fileName.hidden = _fileView.hidden = _fileButton.hidden =YES; - return; - } - if (linphone_content_is_file_transfer(fileContent)) { - _downloadButton.hidden = NO; - _cancelButton.hidden = _fileTransferProgress.hidden = YES; - _playButton.hidden = YES; - _fileName.hidden = _fileView.hidden = _fileButton.hidden = YES; + LinphoneChatMessageState state = linphone_chat_message_get_state(self.message); + if (state != LinphoneChatMessageStateFileTransferDone && state != LinphoneChatMessageStateDisplayed) { + if (state == LinphoneChatMessageStateFileTransferInProgress) { + _cancelButton.hidden = _fileTransferProgress.hidden = NO; + _downloadButton.hidden = YES; + _playButton.hidden = YES; + _fileName.hidden = _fileView.hidden = _fileButton.hidden =YES; + } else { + _downloadButton.hidden = NO; + _cancelButton.hidden = _fileTransferProgress.hidden = YES; + _playButton.hidden = YES; + _fileName.hidden = _fileView.hidden = _fileButton.hidden = YES; + } return; } } - + NSString *fileType = [NSString stringWithUTF8String:linphone_content_get_type(fileContent)]; NSString *fileName = [NSString stringWithUTF8String:linphone_content_get_name(fileContent)]; NSString *filePath = [[LinphoneManager cacheDirectory] stringByAppendingPathComponent:fileName]; if (![[NSFileManager defaultManager] fileExistsAtPath:filePath]) { - NSString *tempName = (localImage?:(localVideo?:localFile)); - if ([tempName isEqualToString:fileName]) { - filePath = [[VIEW(ChatConversationView) getICloudFileUrl:fileName] path]; - } else { - filePath = [[LinphoneManager cacheDirectory] stringByAppendingPathComponent:tempName]; - } + filePath = [[LinphoneManager cacheDirectory] stringByAppendingPathComponent:(localImage?:(localVideo?:localFile))]; } if ([[NSFileManager defaultManager] fileExistsAtPath:filePath]) { @@ -536,6 +532,7 @@ static const CGFloat CELL_IMAGE_X_MARGIN = 100; } else { ChatConversationView *view = VIEW(ChatConversationView); [view.tableController updateEventEntry:self.event]; + [view.tableController scrollToBottom:true]; } } - (void)onFileTransferRecvUpdate:(NSNotification *)notif { @@ -547,6 +544,7 @@ static const CGFloat CELL_IMAGE_X_MARGIN = 100; } else { ChatConversationView *view = VIEW(ChatConversationView); [view.tableController updateEventEntry:self.event]; + [view.tableController scrollToBottom:true]; } } diff --git a/Classes/LinphoneUI/UIChatBubbleTextCell.m b/Classes/LinphoneUI/UIChatBubbleTextCell.m index fb89b4176..4522ff5b9 100644 --- a/Classes/LinphoneUI/UIChatBubbleTextCell.m +++ b/Classes/LinphoneUI/UIChatBubbleTextCell.m @@ -312,6 +312,7 @@ static void message_status(LinphoneChatMessage *msg, LinphoneChatMessageState st LinphoneEventLog *event = (LinphoneEventLog *)linphone_chat_message_cbs_get_user_data(linphone_chat_message_get_callbacks(msg)); ChatConversationView *view = VIEW(ChatConversationView); [view.tableController updateEventEntry:event]; + [view.tableController scrollToBottom:true]; } static void participant_imdn_status(LinphoneChatMessage* msg, const LinphoneParticipantImdnState *state) {