From 712ba1f100212b7171881319c01b94060b677d72 Mon Sep 17 00:00:00 2001 From: Benjamin Reis Date: Wed, 28 Feb 2018 15:43:05 +0100 Subject: [PATCH] better management of chat room cbs --- Classes/ChatsListTableView.m | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Classes/ChatsListTableView.m b/Classes/ChatsListTableView.m index 5588dbbab..ff9e5a84c 100644 --- a/Classes/ChatsListTableView.m +++ b/Classes/ChatsListTableView.m @@ -162,6 +162,15 @@ static int sorted_history_comparison(LinphoneChatRoom *to_insert, LinphoneChatRo LinphoneChatRoom *chatRoom = (LinphoneChatRoom *)bctbx_list_nth_data(_data, (int)[indexPath row]); ChatConversationView *view = VIEW(ChatConversationView); + LinphoneChatRoom *oldRoom = view.chatRoom; + if (oldRoom) { + LinphoneChatRoomCbs *oldCbs = linphone_chat_room_get_current_callbacks(oldRoom); + if (oldCbs && view.chatRoomCbs && oldCbs == view.chatRoomCbs) { + linphone_chat_room_remove_callbacks(oldRoom, view.chatRoomCbs); + view.chatRoomCbs = NULL; + } + } + view.chatRoom = chatRoom; // on iPad, force unread bubble to disappear by reloading the cell if (IPAD) {