diff --git a/src/conversationmodel.cpp b/src/conversationmodel.cpp index b6a88323440856cf0227fd7aaf61850f2d8bfb4f..b2a4bf1f5d524c0c09576c03484c3bcd95106ad1 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 b20b157fe850e2dd19a5457be1f7ee308c8dcaed..c921d7d631a06d578d97e7b57bf5b52e0227f2a0 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); }