diff --git a/Classes/ChatsListTableView.m b/Classes/ChatsListTableView.m index ab767729e..5b76ae1ee 100644 --- a/Classes/ChatsListTableView.m +++ b/Classes/ChatsListTableView.m @@ -162,24 +162,13 @@ static int sorted_history_comparison(LinphoneChatRoom *to_insert, LinphoneChatRo return; 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; - } - } + [PhoneMainView.instance goToChatRoom:chatRoom]; - view.chatRoom = chatRoom; // on iPad, force unread bubble to disappear by reloading the cell if (IPAD) { UIChatCell *cell = (UIChatCell *)[tableView cellForRowAtIndexPath:indexPath]; [cell updateUnreadBadge]; - [view configureForRoom:false]; } - [PhoneMainView.instance changeCurrentView:view.compositeViewDescription]; } void deletion_chat_room_state_changed(LinphoneChatRoom *cr, LinphoneChatRoomState newState) { diff --git a/Classes/LinphoneAppDelegate.m b/Classes/LinphoneAppDelegate.m index b9c0e2815..c2f2db77e 100644 --- a/Classes/LinphoneAppDelegate.m +++ b/Classes/LinphoneAppDelegate.m @@ -667,9 +667,7 @@ didInvalidatePushTokenForType:(NSString *)type { LinphoneAddress *local = linphone_address_new(local_address.UTF8String); LinphoneChatRoom *room = linphone_core_find_chat_room(LC, peer, local); if (room) { - ChatConversationView *view = VIEW(ChatConversationView); - view.chatRoom = room; - [PhoneMainView.instance changeCurrentView:view.compositeViewDescription]; + [PhoneMainView.instance goToChatRoom:room]; return; } [PhoneMainView.instance changeCurrentView:ChatsListView.compositeViewDescription]; diff --git a/Classes/PhoneMainView.h b/Classes/PhoneMainView.h index 3d3f39c3b..d9f1e0d66 100644 --- a/Classes/PhoneMainView.h +++ b/Classes/PhoneMainView.h @@ -110,6 +110,7 @@ - (void)updateApplicationBadgeNumber; - (void)getOrCreateOneToOneChatRoom:(const LinphoneAddress *)remoteAddress waitView:(UIView *)waitView; - (void)createChatRoomWithSubject:(const char *)subject addresses:(bctbx_list_t *)addresses andWaitView:(UIView *)waitView; +- (void)goToChatRoom:(LinphoneChatRoom *)cr; + (PhoneMainView*) instance; - (BOOL)isIphoneXDevice; diff --git a/Classes/PhoneMainView.m b/Classes/PhoneMainView.m index 282bcf085..761eeab14 100644 --- a/Classes/PhoneMainView.m +++ b/Classes/PhoneMainView.m @@ -871,9 +871,8 @@ static RootViewManager *rootViewManagerInstance = nil; bctbx_list_free(addresses); return; } - ChatConversationView *view = VIEW(ChatConversationView); - view.chatRoom = room; - [self changeCurrentView:view.compositeViewDescription]; + + [self goToChatRoom:room]; } - (void)createChatRoomWithSubject:(const char *)subject addresses:(bctbx_list_t *)addresses andWaitView:(UIView *)waitView { @@ -918,7 +917,15 @@ static RootViewManager *rootViewManagerInstance = nil; _waitView.hidden = YES; _waitView = NULL; ChatConversationView *view = VIEW(ChatConversationView); + if (view.chatRoom && view.chatRoomCbs) + linphone_chat_room_remove_callbacks(view.chatRoom, view.chatRoomCbs); + + if (PhoneMainView.instance.currentView == view.compositeViewDescription) + [PhoneMainView.instance popCurrentView]; + + view.chatRoomCbs = NULL; view.chatRoom = cr; + self.currentRoom = view.chatRoom; [PhoneMainView.instance changeCurrentView:view.compositeViewDescription]; }