mirror of
https://git.jami.net/savoirfairelinux/jami-client-qt.git
synced 2025-09-10 12:03:18 +02:00
chatview: fix datatransfer messages not showing
99254f8d02
introduced 2 issues:
- transfer messages not notifying the UI
- some file URLs being erased after loading the conversation
This commit addresses both of them.
Gitlab: #1671
Change-Id: I67a003ea1149c27e749efffe496f4c9ce86615ea
This commit is contained in:
parent
78389d8c28
commit
d2eba1d91e
1 changed files with 22 additions and 15 deletions
|
@ -201,8 +201,12 @@ MessageListModel::update(const QString& id, const interaction::Info& interaction
|
|||
return true;
|
||||
}
|
||||
}
|
||||
// Just update bodies notify the view otherwise.
|
||||
current.body = interaction.body;
|
||||
// TODO: look into why this update with an empty body is broadcasted just
|
||||
// after loading the messages. This is a workaround to avoid the empty
|
||||
// file transfer path. Until then, don't update the body if it's empty.
|
||||
if (!interaction.body.isEmpty()) {
|
||||
current.body = interaction.body;
|
||||
}
|
||||
current.commit = interaction.commit;
|
||||
current.previousBodies = interaction.previousBodies;
|
||||
current.parsedBody = interaction.parsedBody;
|
||||
|
@ -253,21 +257,24 @@ MessageListModel::updateTransferStatus(const QString& id,
|
|||
interaction::TransferStatus newStatus,
|
||||
const QString& newBody)
|
||||
{
|
||||
const std::lock_guard<std::recursive_mutex> lk(mutex_);
|
||||
auto it = find(id);
|
||||
if (it == interactions_.end()) {
|
||||
return false;
|
||||
}
|
||||
VectorInt roles;
|
||||
if (it->second.transferStatus == newStatus) {
|
||||
with(id, [&](const QString&, interaction::Info& interaction) {
|
||||
if (interaction.transferStatus == newStatus) {
|
||||
return;
|
||||
}
|
||||
interaction.transferStatus = newStatus;
|
||||
roles.push_back(Role::TransferStatus);
|
||||
if (!newBody.isEmpty()) {
|
||||
interaction.body = newBody;
|
||||
roles.push_back(Role::Body);
|
||||
}
|
||||
});
|
||||
if (roles.empty()) {
|
||||
return false;
|
||||
}
|
||||
it->second.transferStatus = newStatus;
|
||||
roles.push_back(Role::TransferStatus);
|
||||
if (!newBody.isEmpty()) {
|
||||
it->second.body = newBody;
|
||||
roles.push_back(Role::Body);
|
||||
}
|
||||
auto idx = indexOfMessage(id);
|
||||
auto modelIndex = QAbstractListModel::index(idx, 0);
|
||||
Q_EMIT dataChanged(modelIndex, modelIndex, roles);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -525,7 +532,7 @@ MessageListModel::dataForItem(const item_t& item, int, int role) const
|
|||
auto bestName = item.second.authorUri == account_->profileInfo.uri
|
||||
? account_->accountModel->bestNameForAccount(account_->id)
|
||||
: account_->contactModel->bestNameForContact(
|
||||
item.second.authorUri);
|
||||
item.second.authorUri);
|
||||
return QVariant(
|
||||
interaction::getContactInteractionString(bestName,
|
||||
interaction::to_action(
|
||||
|
|
Loading…
Add table
Reference in a new issue