- remove chatroom from timeline that is at termined or deleted state.

This commit is contained in:
Julien Wadel 2022-03-29 17:43:24 +02:00
parent 3df0067d05
commit a96ab65805
3 changed files with 20 additions and 12 deletions

View file

@ -140,12 +140,14 @@ std::shared_ptr<TimelineModel> TimelineListModel::getTimeline(std::shared_ptr<li
}
if(create){
std::shared_ptr<TimelineModel> model = TimelineModel::create(chatRoom);
if(model){
//std::shared_ptr<TimelineModel> model = std::make_shared<TimelineModel>(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<std::shared_ptr<linphone::ChatRoom>> allChatRooms = coreManager->getCore()->getChatRooms();
// Clean terminated chat rooms.
allChatRooms.remove_if([](std::shared_ptr<linphone::ChatRoom> 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_ptr<linphone::C
connect(model->getChatRoomModel(), &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);
}
}

View file

@ -37,7 +37,7 @@
// =============================================================================
std::shared_ptr<TimelineModel> TimelineModel::create(std::shared_ptr<linphone::ChatRoom> chatRoom, const std::list<std::shared_ptr<linphone::CallLog>>& 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<TimelineModel> model = std::make_shared<TimelineModel>(chatRoom, parent);
if(model && model->getChatRoomModel()){
model->mSelf = model;

View file

@ -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<TimelineModel*>();
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)