diff --git a/Classes/ChatConversationInfoView.m b/Classes/ChatConversationInfoView.m index 0005b52cb..eba335a4f 100644 --- a/Classes/ChatConversationInfoView.m +++ b/Classes/ChatConversationInfoView.m @@ -116,6 +116,18 @@ static UICompositeViewDescription *compositeDescription = nil; [_tableView reloadData]; } +- (void)viewWillDisappear:(BOOL)animated { + if (_room) { + LinphoneChatRoomCbs *cbs = linphone_chat_room_get_callbacks(_room); + linphone_chat_room_cbs_set_state_changed(cbs, NULL); + linphone_chat_room_cbs_set_subject_changed(cbs, NULL); + linphone_chat_room_cbs_set_participant_added(cbs, NULL); + linphone_chat_room_cbs_set_participant_removed(cbs, NULL); + linphone_chat_room_cbs_set_participant_admin_status_changed(cbs, NULL); + linphone_chat_room_cbs_set_user_data(cbs, NULL); + } +} + #pragma mark - next functions - (void)onCreate { diff --git a/Classes/ChatsListTableView.m b/Classes/ChatsListTableView.m index 7a8bfaecd..b2b81d8c7 100644 --- a/Classes/ChatsListTableView.m +++ b/Classes/ChatsListTableView.m @@ -68,8 +68,8 @@ #pragma mark - static int sorted_history_comparison(LinphoneChatRoom *to_insert, LinphoneChatRoom *elem) { - LinphoneChatMessage *last_new_message = linphone_chat_room_get_user_data(to_insert); - LinphoneChatMessage *last_elem_message = linphone_chat_room_get_user_data(elem); + LinphoneChatMessage *last_new_message = linphone_chat_room_get_last_message_in_history(to_insert); + LinphoneChatMessage *last_elem_message = linphone_chat_room_get_last_message_in_history(elem); if (last_new_message && last_elem_message) { time_t new = linphone_chat_message_get_time(last_new_message); @@ -90,8 +90,6 @@ static int sorted_history_comparison(LinphoneChatRoom *to_insert, LinphoneChatRo while (iter) { // store last message in user data LinphoneChatRoom *chat_room = iter->data; - LinphoneChatMessage *last_msg = linphone_chat_room_get_last_message_in_history(chat_room); - linphone_chat_room_set_user_data(chat_room, last_msg); sorted = bctbx_list_insert_sorted(sorted, chat_room, (bctbx_compare_func)sorted_history_comparison); iter = iter->next; } diff --git a/Classes/LinphoneUI/UIChatCell.m b/Classes/LinphoneUI/UIChatCell.m index 01e36743c..eea1cb148 100644 --- a/Classes/LinphoneUI/UIChatCell.m +++ b/Classes/LinphoneUI/UIChatCell.m @@ -92,7 +92,6 @@ _chatLatestTimeLabel.text = [LinphoneUtils timeToString:linphone_chat_message_get_time(last_msg) withFormat:LinphoneDateChatList]; _chatLatestTimeLabel.hidden = NO; - linphone_chat_room_set_user_data(chatRoom, NULL); } else { _chatContentLabel.text = nil; _chatLatestTimeLabel.text = NSLocalizedString(@"Now", nil); diff --git a/Classes/PhoneMainView.m b/Classes/PhoneMainView.m index 126b0ddc6..af54626e9 100644 --- a/Classes/PhoneMainView.m +++ b/Classes/PhoneMainView.m @@ -868,7 +868,6 @@ static RootViewManager *rootViewManagerInstance = nil; LinphoneChatRoomCbs *cbs = linphone_chat_room_get_callbacks(room); linphone_chat_room_cbs_set_state_changed(cbs, main_view_chat_room_state_changed); - linphone_chat_room_cbs_set_user_data(cbs, (__bridge void*)self); linphone_chat_room_add_participants(room, addresses); }