From 605461ff9fd8d71fc090dc4714b7050c5e074bef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Blin?= <sebastien.blin@savoirfairelinux.com> Date: Thu, 26 Sep 2019 16:41:44 -0400 Subject: [PATCH] conversationmodel: clean confId and fix selection when ending a call Change-Id: I8e0e6f0e54a5f537b1719a3e46d452a9db8f2072 --- src/conversationmodel.cpp | 14 ++++++++++++-- src/newcallmodel.cpp | 1 - 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/conversationmodel.cpp b/src/conversationmodel.cpp index b6a88323..b2a4bf1f 100644 --- a/src/conversationmodel.cpp +++ b/src/conversationmodel.cpp @@ -428,9 +428,17 @@ ConversationModel::selectConversation(const std::string& uid) const } auto& conversation = pimpl_->conversations.at(conversationIdx); - if (not conversation.confId.empty()) { + bool callEnded = true; + if (!conversation.callId.empty()) { + try { + auto call = owner.callModel->getCall(conversation.callId); + callEnded = call.status == call::Status::ENDED; + } catch (...) {} + } + + if (not callEnded and not conversation.confId.empty()) { emit pimpl_->behaviorController.showCallView(owner.id, conversation); - } else if (conversation.callId.empty()) { + } else if (callEnded) { emit pimpl_->behaviorController.showChatView(owner.id, conversation); } else { try { @@ -1561,7 +1569,9 @@ ConversationModelPimpl::slotCallEnded(const std::string& callId) for (auto& conversation: conversations) if (conversation.callId == callId) { conversation.callId = ""; + conversation.confId = ""; // The participant is detached dirtyConversations = {true, true}; + emit linked.conversationUpdated(conversation.uid); } } catch (std::out_of_range& e) { qDebug() << "ConversationModelPimpl::slotCallEnded can't end inexistant call"; diff --git a/src/newcallmodel.cpp b/src/newcallmodel.cpp index b20b157f..c921d7d6 100644 --- a/src/newcallmodel.cpp +++ b/src/newcallmodel.cpp @@ -697,7 +697,6 @@ NewCallModelPimpl::slotCallStateChanged(const std::string& callId, const std::st setCurrentCall(callId); call->startTime = std::chrono::steady_clock::now(); - setCurrentCall(callId); emit linked.callStarted(callId); sendProfile(callId); } -- GitLab