From 45b1b60ac1d9d00283b4ae82255f01659e3588dd Mon Sep 17 00:00:00 2001 From: Benjamin Reis Date: Tue, 7 Nov 2017 15:08:06 +0100 Subject: [PATCH] use linphone_chat_room_get_history_events instead of linphone_chat_room_get_history --- Classes/ChatsListTableView.m | 12 +++++++++--- Classes/SettingsView.m | 20 +++++++++++++------- TestsUI/ChatTester.m | 2 +- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/Classes/ChatsListTableView.m b/Classes/ChatsListTableView.m index 54afa25b9..87cbb857d 100644 --- a/Classes/ChatsListTableView.m +++ b/Classes/ChatsListTableView.m @@ -96,11 +96,17 @@ static int sorted_history_comparison(LinphoneChatRoom *to_insert, LinphoneChatRo while (iter) { // store last message in user data LinphoneChatRoom *chat_room = iter->data; - bctbx_list_t *history = linphone_chat_room_get_history(iter->data, 1); + bctbx_list_t *history = linphone_chat_room_get_history_events(iter->data, 1); LinphoneChatMessage *last_msg = NULL; - if (history) { - last_msg = linphone_chat_message_ref(history->data); + while (history) { + LinphoneEventLog *event = history->data; + if (linphone_event_log_get_type(event) != LinphoneEventLogTypeConferenceChatMessage) { + history = history->next; + continue; + } + last_msg = linphone_chat_message_ref(linphone_event_log_get_chat_message(event)); bctbx_list_free(history); + break; } linphone_chat_room_set_user_data(chat_room, last_msg); sorted = bctbx_list_insert_sorted(sorted, linphone_chat_room_ref(chat_room), diff --git a/Classes/SettingsView.m b/Classes/SettingsView.m index f045126b2..d23d7d61b 100644 --- a/Classes/SettingsView.m +++ b/Classes/SettingsView.m @@ -760,14 +760,20 @@ void update_hash_cbs(LinphoneAccountCreator *creator, LinphoneAccountCreatorStat } else if ([key isEqual:@"flush_images_button"]) { const MSList *rooms = linphone_core_get_chat_rooms(LC); while (rooms) { - const MSList *messages = linphone_chat_room_get_history(rooms->data, 0); - while (messages) { - LinphoneChatMessage *msg = messages->data; - if (!linphone_chat_message_is_outgoing(msg)) { - [LinphoneManager setValueInMessageAppData:nil forKey:@"localimage" inMessage:messages->data]; - [LinphoneManager setValueInMessageAppData:nil forKey:@"uploadQuality" inMessage:messages->data]; + const MSList *events = linphone_chat_room_get_history_events(rooms->data, 0); + while (events) { + LinphoneEventLog *event = events->data; + if (linphone_event_log_get_type(event) != LinphoneEventLogTypeConferenceChatMessage) { + events = events->next; + continue; } - messages = messages->next; + + LinphoneChatMessage *msg = linphone_event_log_get_chat_message(event); + if (!linphone_chat_message_is_outgoing(msg)) { + [LinphoneManager setValueInMessageAppData:nil forKey:@"localimage" inMessage:events->data]; + [LinphoneManager setValueInMessageAppData:nil forKey:@"uploadQuality" inMessage:events->data]; + } + events = events->next; } rooms = rooms->next; } diff --git a/TestsUI/ChatTester.m b/TestsUI/ChatTester.m index c7e9f96c1..9c4031a04 100644 --- a/TestsUI/ChatTester.m +++ b/TestsUI/ChatTester.m @@ -194,7 +194,7 @@ for (int i = 0; i < 50; i++) { [tester waitForTimeInterval:.5f]; - if (bctbx_list_size(linphone_chat_room_get_history(room, 0)) == count) { + if (bctbx_list_size(linphone_chat_room_get_history_events(room, 0)) == count) { break; } }