mirror of
https://git.jami.net/savoirfairelinux/jami-client-qt.git
synced 2025-09-09 19:43:31 +02:00
conversationlist: save linked account
This avoid some "contact not found" messages if a delegate is checked while changing the account. Change-Id: I05c4affa93a972ac95578507bd8263706e90298b
This commit is contained in:
parent
a5de0d4196
commit
9207dfcd5b
2 changed files with 18 additions and 13 deletions
|
@ -23,7 +23,12 @@ ConversationListModelBase::ConversationListModelBase(LRCInstance* instance, QObj
|
||||||
: AbstractListModelBase(parent)
|
: AbstractListModelBase(parent)
|
||||||
{
|
{
|
||||||
lrcInstance_ = instance;
|
lrcInstance_ = instance;
|
||||||
model_ = lrcInstance_->getCurrentConversationModel();
|
try {
|
||||||
|
auto& accInfo = lrcInstance_->getCurrentAccountInfo();
|
||||||
|
accountId_ = accInfo.id;
|
||||||
|
model_ = accInfo.conversationModel.get();
|
||||||
|
} catch (...) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -47,12 +52,12 @@ ConversationListModelBase::roleNames() const
|
||||||
QVariant
|
QVariant
|
||||||
ConversationListModelBase::dataForItem(item_t item, int role) const
|
ConversationListModelBase::dataForItem(item_t item, int role) const
|
||||||
{
|
{
|
||||||
|
auto& accInfo = lrcInstance_->getAccountInfo(accountId_);
|
||||||
switch (role) {
|
switch (role) {
|
||||||
case Role::InCall: {
|
case Role::InCall: {
|
||||||
const auto& convInfo = lrcInstance_->getConversationFromConvUid(item.uid);
|
const auto& convInfo = lrcInstance_->getConversationFromConvUid(item.uid);
|
||||||
if (!convInfo.uid.isEmpty()) {
|
if (!convInfo.uid.isEmpty()) {
|
||||||
auto* callModel = lrcInstance_->getCurrentCallModel();
|
return QVariant(accInfo.callModel->hasCall(convInfo.callId));
|
||||||
return QVariant(callModel->hasCall(convInfo.callId));
|
|
||||||
}
|
}
|
||||||
return QVariant(false);
|
return QVariant(false);
|
||||||
}
|
}
|
||||||
|
@ -69,9 +74,8 @@ ConversationListModelBase::dataForItem(item_t item, int role) const
|
||||||
case Role::CallStackViewShouldShow: {
|
case Role::CallStackViewShouldShow: {
|
||||||
const auto& convInfo = lrcInstance_->getConversationFromConvUid(item.uid);
|
const auto& convInfo = lrcInstance_->getConversationFromConvUid(item.uid);
|
||||||
if (!convInfo.uid.isEmpty() && !convInfo.callId.isEmpty()) {
|
if (!convInfo.uid.isEmpty() && !convInfo.callId.isEmpty()) {
|
||||||
auto* callModel = lrcInstance_->getCurrentCallModel();
|
const auto& call = accInfo.callModel->getCall(convInfo.callId);
|
||||||
const auto& call = callModel->getCall(convInfo.callId);
|
return QVariant(accInfo.callModel->hasCall(convInfo.callId)
|
||||||
return QVariant(callModel->hasCall(convInfo.callId)
|
|
||||||
&& ((!call.isOutgoing
|
&& ((!call.isOutgoing
|
||||||
&& (call.status == call::Status::IN_PROGRESS
|
&& (call.status == call::Status::IN_PROGRESS
|
||||||
|| call.status == call::Status::PAUSED
|
|| call.status == call::Status::PAUSED
|
||||||
|
@ -141,7 +145,7 @@ ConversationListModelBase::dataForItem(item_t item, int role) const
|
||||||
QStringList ret;
|
QStringList ret;
|
||||||
Q_FOREACH (const auto& peerUri, model_->peersForConversation(item.uid))
|
Q_FOREACH (const auto& peerUri, model_->peersForConversation(item.uid))
|
||||||
try {
|
try {
|
||||||
auto& accInfo = lrcInstance_->getCurrentAccountInfo();
|
auto& accInfo = lrcInstance_->getAccountInfo(accountId_);
|
||||||
auto contact = accInfo.contactModel->getContact(peerUri);
|
auto contact = accInfo.contactModel->getContact(peerUri);
|
||||||
ret << contact.profileInfo.alias << contact.registeredName;
|
ret << contact.profileInfo.alias << contact.registeredName;
|
||||||
} catch (const std::exception&) {
|
} catch (const std::exception&) {
|
||||||
|
@ -152,7 +156,7 @@ ConversationListModelBase::dataForItem(item_t item, int role) const
|
||||||
// The conversation can show a green dot if at least one peer is present
|
// The conversation can show a green dot if at least one peer is present
|
||||||
Q_FOREACH (const auto& peerUri, model_->peersForConversation(item.uid))
|
Q_FOREACH (const auto& peerUri, model_->peersForConversation(item.uid))
|
||||||
try {
|
try {
|
||||||
auto& accInfo = lrcInstance_->getCurrentAccountInfo();
|
auto& accInfo = lrcInstance_->getAccountInfo(accountId_);
|
||||||
if (peerUri == accInfo.profileInfo.uri)
|
if (peerUri == accInfo.profileInfo.uri)
|
||||||
return true; // Self account
|
return true; // Self account
|
||||||
auto contact = accInfo.contactModel->getContact(peerUri);
|
auto contact = accInfo.contactModel->getContact(peerUri);
|
||||||
|
@ -171,7 +175,7 @@ ConversationListModelBase::dataForItem(item_t item, int role) const
|
||||||
if (peerUriList.isEmpty())
|
if (peerUriList.isEmpty())
|
||||||
return {};
|
return {};
|
||||||
auto peerUri = peerUriList.at(0);
|
auto peerUri = peerUriList.at(0);
|
||||||
auto& accInfo = lrcInstance_->getCurrentAccountInfo();
|
auto& accInfo = lrcInstance_->getAccountInfo(accountId_);
|
||||||
if (peerUri == accInfo.profileInfo.uri) {
|
if (peerUri == accInfo.profileInfo.uri) {
|
||||||
// Conversation alone with self
|
// Conversation alone with self
|
||||||
switch (role) {
|
switch (role) {
|
||||||
|
@ -186,8 +190,7 @@ ConversationListModelBase::dataForItem(item_t item, int role) const
|
||||||
case Role::IsBanned:
|
case Role::IsBanned:
|
||||||
return QVariant(false);
|
return QVariant(false);
|
||||||
case Role::ContactType:
|
case Role::ContactType:
|
||||||
return QVariant(
|
return QVariant(static_cast<int>(accInfo.profileInfo.type));
|
||||||
static_cast<int>(accInfo.profileInfo.type));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ContactModel* contactModel;
|
ContactModel* contactModel;
|
||||||
|
@ -196,8 +199,9 @@ ConversationListModelBase::dataForItem(item_t item, int role) const
|
||||||
try {
|
try {
|
||||||
contact = contactModel->getContact(peerUri);
|
contact = contactModel->getContact(peerUri);
|
||||||
} catch (const std::exception&) {
|
} catch (const std::exception&) {
|
||||||
qWarning() << Q_FUNC_INFO << "Can't find contact" << peerUri
|
qWarning() << Q_FUNC_INFO << "Can't find contact" << peerUri << " for account "
|
||||||
<< " this is a bug, please report";
|
<< lrcInstance_->accountModel().bestNameForAccount(accInfo.id)
|
||||||
|
<< " - Conv: " << item.uid;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (role) {
|
switch (role) {
|
||||||
|
|
|
@ -81,4 +81,5 @@ protected:
|
||||||
|
|
||||||
// Convenience pointer to be pulled from lrcinstance
|
// Convenience pointer to be pulled from lrcinstance
|
||||||
ConversationModel* model_;
|
ConversationModel* model_;
|
||||||
|
QString accountId_;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue