keep enhancing chatroom sorting

This commit is contained in:
Benjamin Reis 2018-02-13 15:56:57 +01:00
parent 745ce34ded
commit 8e855e2364
3 changed files with 9 additions and 21 deletions

View file

@ -84,21 +84,14 @@
#pragma mark -
static int sorted_history_comparison(LinphoneChatRoom *to_insert, LinphoneChatRoom *elem) {
LinphoneEventLog *last_new_event = (LinphoneEventLog *)linphone_chat_room_get_history_events(to_insert, 1) ? linphone_chat_room_get_history_events(to_insert, 1)->data : NULL;
LinphoneEventLog *last_elem_event = (LinphoneEventLog *)linphone_chat_room_get_history_events(elem, 1) ? linphone_chat_room_get_history_events(elem, 1)->data : NULL;
if (last_new_event && last_elem_event) {
time_t new = linphone_event_log_get_creation_time(last_new_event);
time_t old = linphone_event_log_get_creation_time(last_elem_event);
if (new < old)
return 1;
else if (new > old)
return -1;
}
if (last_new_event)
time_t new = linphone_chat_room_get_last_update_time(to_insert);
time_t old = linphone_chat_room_get_last_update_time(elem);
if (new < old)
return 1;
else if (new > old)
return -1;
return 1;
return 0;
}
- (MSList *)sortChatRooms {

View file

@ -81,12 +81,7 @@
[_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;
_chatLatestTimeLabel.hidden = !last_event;
if (last_event)
_chatLatestTimeLabel.text = [LinphoneUtils timeToString:linphone_event_log_get_creation_time(last_event) withFormat:LinphoneDateChatList];
_chatLatestTimeLabel.text = [LinphoneUtils timeToString:linphone_chat_room_get_last_update_time(chatRoom) withFormat:LinphoneDateChatList];
LinphoneChatMessage *last_msg = linphone_chat_room_get_last_message_in_history(chatRoom);
if (last_msg) {

@ -1 +1 @@
Subproject commit 107aa11e139df6b3ab76f18930e75b9129bcbad7
Subproject commit 9f5a74bd4232c14d9be52dd81aea4bf4cc03402b