diff --git a/linphone-app/src/components/timeline/TimelineListModel.cpp b/linphone-app/src/components/timeline/TimelineListModel.cpp index 1b3d1f0ce..11d7cc99e 100644 --- a/linphone-app/src/components/timeline/TimelineListModel.cpp +++ b/linphone-app/src/components/timeline/TimelineListModel.cpp @@ -140,12 +140,14 @@ std::shared_ptr TimelineListModel::getTimeline(std::shared_ptr
  • model = TimelineModel::create(chatRoom); + if(model){ //std::shared_ptr model = std::make_shared(chatRoom); - connect(model.get(), SIGNAL(selectedChanged(bool)), this, SLOT(onSelectedHasChanged(bool))); - connect(model->getChatRoomModel(), &ChatRoomModel::allEntriesRemoved, this, &TimelineListModel::removeChatRoomModel); - add(model); + connect(model.get(), SIGNAL(selectedChanged(bool)), this, SLOT(onSelectedHasChanged(bool))); + connect(model->getChatRoomModel(), &ChatRoomModel::allEntriesRemoved, this, &TimelineListModel::removeChatRoomModel); + add(model); //connect(model.get(), SIGNAL(conferenceLeft()), this, SLOT(selectedHasChanged(bool))); - return model; + return model; + } } } return nullptr; @@ -240,8 +242,12 @@ void TimelineListModel::updateTimelines () { CoreManager *coreManager = CoreManager::getInstance(); std::list> allChatRooms = coreManager->getCore()->getChatRooms(); +// Clean terminated chat rooms. + allChatRooms.remove_if([](std::shared_ptr chatRoom){ + return chatRoom->getState() == linphone::ChatRoom::State::Terminated || chatRoom->getState() == linphone::ChatRoom::State::Deleted; + }); - //Remove no more chat rooms +//Remove no more chat rooms auto itTimeline = mTimelines.begin(); while(itTimeline != mTimelines.end()) { auto itDbTimeline = allChatRooms.begin(); @@ -341,7 +347,10 @@ void TimelineListModel::onChatRoomStateChanged(const std::shared_ptrgetChatRoomModel(), &ChatRoomModel::allEntriesRemoved, this, &TimelineListModel::removeChatRoomModel); add(model); } - }else if(state == linphone::ChatRoom::State::Deleted){ + }else if(state == linphone::ChatRoom::State::Deleted || state == linphone::ChatRoom::State::Terminated){ + auto timeline = getTimeline(chatRoom, false); + if(timeline) + remove(timeline); } } diff --git a/linphone-app/src/components/timeline/TimelineModel.cpp b/linphone-app/src/components/timeline/TimelineModel.cpp index 66f59a866..d82d63305 100644 --- a/linphone-app/src/components/timeline/TimelineModel.cpp +++ b/linphone-app/src/components/timeline/TimelineModel.cpp @@ -37,7 +37,7 @@ // ============================================================================= std::shared_ptr TimelineModel::create(std::shared_ptr chatRoom, const std::list>& callLogs, QObject *parent){ - if(!CoreManager::getInstance()->getTimelineListModel() || !CoreManager::getInstance()->getTimelineListModel()->getTimeline(chatRoom, false)) { + if((!chatRoom || chatRoom->getState() != linphone::ChatRoom::State::Terminated) && (!CoreManager::getInstance()->getTimelineListModel() || !CoreManager::getInstance()->getTimelineListModel()->getTimeline(chatRoom, false)) ) { std::shared_ptr model = std::make_shared(chatRoom, parent); if(model && model->getChatRoomModel()){ model->mSelf = model; diff --git a/linphone-app/src/components/timeline/TimelineProxyModel.cpp b/linphone-app/src/components/timeline/TimelineProxyModel.cpp index 92e063b32..e3056e619 100644 --- a/linphone-app/src/components/timeline/TimelineProxyModel.cpp +++ b/linphone-app/src/components/timeline/TimelineProxyModel.cpp @@ -90,17 +90,16 @@ void TimelineProxyModel::setFilterText(const QString& text){ bool TimelineProxyModel::filterAcceptsRow (int sourceRow, const QModelIndex &sourceParent) const { const QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent); auto timeline = sourceModel()->data(index).value(); - if(!timeline || !timeline->getChatRoomModel()) + if(!timeline || !timeline->getChatRoomModel() || timeline->getChatRoomModel()->getState() == (int)linphone::ChatRoom::State::Terminated) return false; - bool show = (mFilterFlags==0);// Show all at 0 (no hide all) - bool isGroup = timeline->getChatRoomModel()->isGroupEnabled(); bool haveEncryption = timeline->getChatRoomModel()->haveEncryption(); - bool isEphemeral = timeline->getChatRoomModel()->isEphemeralEnabled(); - if(!CoreManager::getInstance()->getSettingsModel()->getStandardChatEnabled() && !haveEncryption) return false; if(!CoreManager::getInstance()->getSettingsModel()->getSecureChatEnabled() && haveEncryption) return false; + bool show = (mFilterFlags==0);// Show all at 0 (no hide all) + bool isGroup = timeline->getChatRoomModel()->isGroupEnabled(); + bool isEphemeral = timeline->getChatRoomModel()->isEphemeralEnabled(); if( mFilterFlags > 0) { show = !(( ( (mFilterFlags & TimelineFilter::SimpleChatRoom) == TimelineFilter::SimpleChatRoom) && isGroup)