mirror of
https://git.jami.net/savoirfairelinux/jami-client-qt.git
synced 2025-08-04 06:45:45 +02:00
currentconversation: always set the current conversation id
This must be done even when empty and contributes to the deselection mechanism. Change-Id: Ia97186ad8f37763ed2c8f61f4f44a0a04df7577b
This commit is contained in:
parent
7a844ee1ae
commit
84d625c1b4
1 changed files with 75 additions and 74 deletions
|
@ -51,89 +51,90 @@ void
|
||||||
CurrentConversation::updateData()
|
CurrentConversation::updateData()
|
||||||
{
|
{
|
||||||
auto convId = lrcInstance_->get_selectedConvUid();
|
auto convId = lrcInstance_->get_selectedConvUid();
|
||||||
if (convId.isEmpty())
|
|
||||||
return;
|
auto cleanup = qScopeGuard([&] {
|
||||||
|
set_id(convId);
|
||||||
|
updateErrors(convId);
|
||||||
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
auto accountId = lrcInstance_->get_currentAccountId();
|
auto accountId = lrcInstance_->get_currentAccountId();
|
||||||
const auto& accInfo = lrcInstance_->accountModel().getAccountInfo(accountId);
|
const auto& accInfo = lrcInstance_->accountModel().getAccountInfo(accountId);
|
||||||
if (auto optConv = accInfo.conversationModel->getConversationForUid(convId)) {
|
auto optConv = accInfo.conversationModel->getConversationForUid(convId);
|
||||||
auto& convInfo = optConv->get();
|
if (!optConv)
|
||||||
set_lastSelfMessageId(convInfo.lastSelfMessageId);
|
return;
|
||||||
QStringList uris, bannedUris;
|
auto& convInfo = optConv->get();
|
||||||
auto isAdmin = false;
|
set_lastSelfMessageId(convInfo.lastSelfMessageId);
|
||||||
for (const auto& p : convInfo.participants) {
|
QStringList uris, bannedUris;
|
||||||
if (p.uri == accInfo.profileInfo.uri) {
|
auto isAdmin = false;
|
||||||
isAdmin = p.role == member::Role::ADMIN;
|
for (const auto& p : convInfo.participants) {
|
||||||
}
|
if (p.uri == accInfo.profileInfo.uri) {
|
||||||
if (p.role == member::Role::BANNED) {
|
isAdmin = p.role == member::Role::ADMIN;
|
||||||
bannedUris.push_back(p.uri);
|
|
||||||
} else {
|
|
||||||
uris.push_back(p.uri);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (isAdmin) {
|
if (p.role == member::Role::BANNED) {
|
||||||
for (const auto& banned : bannedUris)
|
bannedUris.push_back(p.uri);
|
||||||
uris.push_back(banned);
|
|
||||||
}
|
|
||||||
uris_->setMembers(accountId, convId, uris);
|
|
||||||
set_isSwarm(convInfo.isSwarm());
|
|
||||||
set_isLegacy(convInfo.isLegacy());
|
|
||||||
set_isCoreDialog(convInfo.isCoreDialog());
|
|
||||||
set_isRequest(convInfo.isRequest);
|
|
||||||
set_needsSyncing(convInfo.needsSyncing);
|
|
||||||
updateConversationPreferences(convId);
|
|
||||||
set_isSip(accInfo.profileInfo.type == profile::Type::SIP);
|
|
||||||
set_callId(convInfo.getCallId());
|
|
||||||
set_allMessagesLoaded(convInfo.allMessagesLoaded);
|
|
||||||
if (accInfo.callModel->hasCall(callId_)) {
|
|
||||||
auto call = accInfo.callModel->getCall(callId_);
|
|
||||||
set_callState(call.status);
|
|
||||||
set_hasCall(callState_ != call::Status::ENDED);
|
|
||||||
} else {
|
} else {
|
||||||
set_callState(call::Status::INVALID);
|
uris.push_back(p.uri);
|
||||||
set_hasCall(false);
|
|
||||||
}
|
}
|
||||||
set_inCall(callState_ == call::Status::CONNECTED
|
|
||||||
|| callState_ == call::Status::IN_PROGRESS
|
|
||||||
|| callState_ == call::Status::PAUSED);
|
|
||||||
|
|
||||||
// The temporary status is only for dialogs.
|
|
||||||
// It can be used to display add contact/conversation UI and
|
|
||||||
// is consistently determined by the peer's uri being equal to
|
|
||||||
// the conversation id.
|
|
||||||
auto members = accInfo.conversationModel->peersForConversation(convId);
|
|
||||||
set_isTemporary(isCoreDialog_ ? (convId == members.at(0) || convId == "SEARCHSIP")
|
|
||||||
: false);
|
|
||||||
|
|
||||||
auto isContact {false};
|
|
||||||
if (isCoreDialog_)
|
|
||||||
try {
|
|
||||||
auto& contact = accInfo.contactModel->getContact(members.at(0));
|
|
||||||
set_isBanned(contact.isBanned);
|
|
||||||
isContact = contact.profileInfo.type != profile::Type::TEMPORARY;
|
|
||||||
} catch (const std::exception& e) {
|
|
||||||
qInfo() << "Contact not found: " << e.what();
|
|
||||||
}
|
|
||||||
set_isContact(isContact);
|
|
||||||
|
|
||||||
if (convInfo.mode == conversation::Mode::ONE_TO_ONE) {
|
|
||||||
set_modeString(tr("Private"));
|
|
||||||
} else if (convInfo.mode == conversation::Mode::ADMIN_INVITES_ONLY) {
|
|
||||||
set_modeString(tr("Private group (restricted invites)"));
|
|
||||||
} else if (convInfo.mode == conversation::Mode::INVITES_ONLY) {
|
|
||||||
set_modeString(tr("Private group"));
|
|
||||||
} else if (convInfo.mode == conversation::Mode::PUBLIC) {
|
|
||||||
set_modeString(tr("Public group"));
|
|
||||||
}
|
|
||||||
|
|
||||||
onProfileUpdated(convId);
|
|
||||||
updateActiveCalls(accountId, convId);
|
|
||||||
}
|
}
|
||||||
|
if (isAdmin) {
|
||||||
|
for (const auto& banned : bannedUris)
|
||||||
|
uris.push_back(banned);
|
||||||
|
}
|
||||||
|
uris_->setMembers(accountId, convId, uris);
|
||||||
|
set_isSwarm(convInfo.isSwarm());
|
||||||
|
set_isLegacy(convInfo.isLegacy());
|
||||||
|
set_isCoreDialog(convInfo.isCoreDialog());
|
||||||
|
set_isRequest(convInfo.isRequest);
|
||||||
|
set_needsSyncing(convInfo.needsSyncing);
|
||||||
|
updateConversationPreferences(convId);
|
||||||
|
set_isSip(accInfo.profileInfo.type == profile::Type::SIP);
|
||||||
|
set_callId(convInfo.getCallId());
|
||||||
|
set_allMessagesLoaded(convInfo.allMessagesLoaded);
|
||||||
|
if (accInfo.callModel->hasCall(callId_)) {
|
||||||
|
auto call = accInfo.callModel->getCall(callId_);
|
||||||
|
set_callState(call.status);
|
||||||
|
set_hasCall(callState_ != call::Status::ENDED);
|
||||||
|
} else {
|
||||||
|
set_callState(call::Status::INVALID);
|
||||||
|
set_hasCall(false);
|
||||||
|
}
|
||||||
|
set_inCall(callState_ == call::Status::CONNECTED || callState_ == call::Status::IN_PROGRESS
|
||||||
|
|| callState_ == call::Status::PAUSED);
|
||||||
|
|
||||||
|
// The temporary status is only for dialogs.
|
||||||
|
// It can be used to display add contact/conversation UI and
|
||||||
|
// is consistently determined by the peer's uri being equal to
|
||||||
|
// the conversation id.
|
||||||
|
auto members = accInfo.conversationModel->peersForConversation(convId);
|
||||||
|
set_isTemporary(isCoreDialog_ ? (convId == members.at(0) || convId == "SEARCHSIP") : false);
|
||||||
|
|
||||||
|
auto isContact {false};
|
||||||
|
if (isCoreDialog_)
|
||||||
|
try {
|
||||||
|
auto& contact = accInfo.contactModel->getContact(members.at(0));
|
||||||
|
set_isBanned(contact.isBanned);
|
||||||
|
isContact = contact.profileInfo.type != profile::Type::TEMPORARY;
|
||||||
|
} catch (const std::exception& e) {
|
||||||
|
qInfo() << "Contact not found: " << e.what();
|
||||||
|
}
|
||||||
|
set_isContact(isContact);
|
||||||
|
|
||||||
|
if (convInfo.mode == conversation::Mode::ONE_TO_ONE) {
|
||||||
|
set_modeString(tr("Private"));
|
||||||
|
} else if (convInfo.mode == conversation::Mode::ADMIN_INVITES_ONLY) {
|
||||||
|
set_modeString(tr("Private group (restricted invites)"));
|
||||||
|
} else if (convInfo.mode == conversation::Mode::INVITES_ONLY) {
|
||||||
|
set_modeString(tr("Private group"));
|
||||||
|
} else if (convInfo.mode == conversation::Mode::PUBLIC) {
|
||||||
|
set_modeString(tr("Public group"));
|
||||||
|
}
|
||||||
|
|
||||||
|
onProfileUpdated(convId);
|
||||||
|
updateActiveCalls(accountId, convId);
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
qWarning() << "Can't update current conversation data for" << convId;
|
qWarning() << "Can't update current conversation data for" << convId;
|
||||||
}
|
}
|
||||||
set_id(convId);
|
|
||||||
updateErrors(convId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -304,7 +305,7 @@ CurrentConversation::showSwarmDetails()
|
||||||
void
|
void
|
||||||
CurrentConversation::updateErrors(const QString& convId)
|
CurrentConversation::updateErrors(const QString& convId)
|
||||||
{
|
{
|
||||||
if (convId != id_)
|
if (convId != id_ || convId.isEmpty())
|
||||||
return;
|
return;
|
||||||
try {
|
try {
|
||||||
QStringList newErrors;
|
QStringList newErrors;
|
||||||
|
|
Loading…
Add table
Reference in a new issue