From 78a1d4514192c13ad1fb230c1a81197c2c8b1576 Mon Sep 17 00:00:00 2001 From: Benjamin Reis Date: Tue, 13 Feb 2018 14:17:21 +0100 Subject: [PATCH] better sort of chat rooms --- Classes/ChatsListTableView.m | 4 ++-- Classes/LinphoneUI/UIChatCell.m | 13 +++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Classes/ChatsListTableView.m b/Classes/ChatsListTableView.m index 661d95815..82ab1bbf9 100644 --- a/Classes/ChatsListTableView.m +++ b/Classes/ChatsListTableView.m @@ -96,9 +96,9 @@ static int sorted_history_comparison(LinphoneChatRoom *to_insert, LinphoneChatRo return -1; } if (last_new_event) - return 1; + return -1; - return -1; + return 1; } - (MSList *)sortChatRooms { diff --git a/Classes/LinphoneUI/UIChatCell.m b/Classes/LinphoneUI/UIChatCell.m index 720b420ca..c75099545 100644 --- a/Classes/LinphoneUI/UIChatCell.m +++ b/Classes/LinphoneUI/UIChatCell.m @@ -81,12 +81,13 @@ [_avatarImage setImage:[UIImage imageNamed:@"chat_group_avatar.png"] bordered:NO withRoundedRadius:YES]; } - LinphoneEventLog *last_event = (LinphoneEventLog *)linphone_chat_room_get_history_events(chatRoom, 1) ? linphone_chat_room_get_history_events(chatRoom, 1)->data : NULL; - if (last_event) { - _chatLatestTimeLabel.text = - [LinphoneUtils timeToString:linphone_event_log_get_creation_time(last_event) withFormat:LinphoneDateChatList]; - _chatLatestTimeLabel.hidden = NO; - } + LinphoneEventLog *last_event = (LinphoneEventLog *)linphone_chat_room_get_history_events(chatRoom, 1) + ? linphone_chat_room_get_history_events(chatRoom, 1)->data + : NULL; + _chatLatestTimeLabel.hidden = !last_event; + if (last_event) + _chatLatestTimeLabel.text = [LinphoneUtils timeToString:linphone_event_log_get_creation_time(last_event) withFormat:LinphoneDateChatList]; + LinphoneChatMessage *last_msg = linphone_chat_room_get_last_message_in_history(chatRoom); if (last_msg) { NSString *message = [UIChatBubbleTextCell TextMessageForChat:last_msg];