mirror of
https://git.jami.net/savoirfairelinux/jami-client-qt.git
synced 2025-09-10 12:03:18 +02:00
callmessagedelegate: fix isOutgoing
Change-Id: Ia4529e9646cd676d15c60f6f48e7ab31fd2bbbc1
This commit is contained in:
parent
4794cc87d3
commit
8d74ad3602
5 changed files with 19 additions and 18 deletions
|
@ -39,7 +39,7 @@ SBSMessageBase {
|
|||
|
||||
property bool isRemoteImage
|
||||
|
||||
isOutgoing: Author === ""
|
||||
isOutgoing: Author === CurrentAccount.uri
|
||||
author: Author
|
||||
readers: Readers
|
||||
formattedTime: MessagesAdapter.getFormattedTime(Timestamp)
|
||||
|
|
|
@ -251,7 +251,7 @@ Loader {
|
|||
SBSMessageBase {
|
||||
id: localMediaMsgItem
|
||||
|
||||
isOutgoing: Author === ""
|
||||
isOutgoing: Author === CurrentAccount.uri
|
||||
showTime: root.showTime
|
||||
seq: root.seq
|
||||
author: Author
|
||||
|
|
|
@ -167,15 +167,15 @@ getFormattedCallDuration(const std::time_t duration)
|
|||
}
|
||||
|
||||
QString
|
||||
getCallInteractionStringNonSwarm(const QString& authorUri, const std::time_t& duration)
|
||||
getCallInteractionStringNonSwarm(bool isSelf, const std::time_t& duration)
|
||||
{
|
||||
if (duration < 0) {
|
||||
if (authorUri.isEmpty()) {
|
||||
if (isSelf) {
|
||||
return QObject::tr("Outgoing call");
|
||||
} else {
|
||||
return QObject::tr("Incoming call");
|
||||
}
|
||||
} else if (authorUri.isEmpty()) {
|
||||
} else if (isSelf) {
|
||||
if (duration) {
|
||||
return QObject::tr("Outgoing call") + " - " + getFormattedCallDuration(duration);
|
||||
} else {
|
||||
|
@ -191,14 +191,14 @@ getCallInteractionStringNonSwarm(const QString& authorUri, const std::time_t& du
|
|||
}
|
||||
|
||||
QString
|
||||
getCallInteractionString(const api::interaction::Info& info)
|
||||
getCallInteractionString(bool isSelf, const api::interaction::Info& info)
|
||||
{
|
||||
if (!info.confId.isEmpty()) {
|
||||
if (info.duration <= 0) {
|
||||
return QObject::tr("Join call");
|
||||
}
|
||||
}
|
||||
return getCallInteractionStringNonSwarm(info.authorUri, info.duration);
|
||||
return getCallInteractionStringNonSwarm(isSelf, info.duration);
|
||||
}
|
||||
|
||||
QString
|
||||
|
@ -497,7 +497,7 @@ beginConversationWithPeer(Database& db,
|
|||
}
|
||||
|
||||
void
|
||||
getHistory(Database& db, api::conversation::Info& conversation)
|
||||
getHistory(Database& db, api::conversation::Info& conversation, const QString& localUri)
|
||||
{
|
||||
auto interactionsResult
|
||||
= db.select("id, author, body, timestamp, type, status, is_read, extra_data",
|
||||
|
@ -521,7 +521,7 @@ getHistory(Database& db, api::conversation::Info& conversation)
|
|||
: std::stoi(durationString.toStdString());
|
||||
auto status = api::interaction::to_status(payloads[i + 5]);
|
||||
if (type == api::interaction::Type::CALL) {
|
||||
body = getCallInteractionStringNonSwarm(payloads[i + 1], duration);
|
||||
body = getCallInteractionStringNonSwarm(payloads[i + 1] == localUri, duration);
|
||||
} else if (type == api::interaction::Type::CONTACT) {
|
||||
body = getContactInteractionString(payloads[i + 1], status);
|
||||
}
|
||||
|
|
|
@ -56,11 +56,12 @@ QString prepareUri(const QString& uri, api::profile::Type type);
|
|||
|
||||
/**
|
||||
* Get a formatted string for a call interaction's body
|
||||
* @param isSelf
|
||||
* @param info
|
||||
* @return the formatted and translated call message string
|
||||
*/
|
||||
QString getCallInteractionString(const api::interaction::Info& info);
|
||||
QString getCallInteractionStringNonSwarm(const QString& authorUri, const std::time_t& duration);
|
||||
QString getCallInteractionString(bool isSelf, const api::interaction::Info& info);
|
||||
QString getCallInteractionStringNonSwarm(bool isSelf, const std::time_t& duration);
|
||||
|
||||
/**
|
||||
* Get a formatted string for a contact interaction's body
|
||||
|
@ -195,7 +196,7 @@ QString beginConversationWithPeer(Database& db,
|
|||
* @param db
|
||||
* @param conversation to modify
|
||||
*/
|
||||
void getHistory(Database& db, api::conversation::Info& conversation);
|
||||
void getHistory(Database& db, api::conversation::Info& conversation, const QString& localUri);
|
||||
|
||||
/**
|
||||
* Add an entry into interactions linked to a conversation.
|
||||
|
|
|
@ -1457,7 +1457,7 @@ ConversationModel::clearHistory(const QString& uid)
|
|||
std::lock_guard<std::mutex> lk(pimpl_->interactionsLocks[conversation.uid]);
|
||||
conversation.interactions->clear();
|
||||
}
|
||||
storage::getHistory(pimpl_->db, conversation); // will contain "Conversation started"
|
||||
storage::getHistory(pimpl_->db, conversation, pimpl_->linked.owner.profileInfo.uri); // will contain "Conversation started"
|
||||
|
||||
Q_EMIT modelChanged();
|
||||
Q_EMIT conversationCleared(uid);
|
||||
|
@ -1639,7 +1639,7 @@ ConversationModel::clearAllHistory()
|
|||
std::lock_guard<std::mutex> lk(pimpl_->interactionsLocks[conversation.uid]);
|
||||
conversation.interactions->clear();
|
||||
}
|
||||
storage::getHistory(pimpl_->db, conversation);
|
||||
storage::getHistory(pimpl_->db, conversation, pimpl_->linked.owner.profileInfo.uri);
|
||||
Q_EMIT dataChanged(pimpl_->indexOf(conversation.uid));
|
||||
}
|
||||
Q_EMIT modelChanged();
|
||||
|
@ -2480,7 +2480,7 @@ ConversationModelPimpl::slotConversationLoaded(uint32_t requestId,
|
|||
linked.owner.dataTransferModel->registerTransferId(fileId, msgId);
|
||||
downloadFile = (bytesProgress == 0);
|
||||
} else if (msg.type == interaction::Type::CALL) {
|
||||
msg.body = storage::getCallInteractionString(msg);
|
||||
msg.body = storage::getCallInteractionString(msg.authorUri == linked.owner.profileInfo.uri, msg);
|
||||
} else if (msg.type == interaction::Type::CONTACT) {
|
||||
auto bestName = msg.authorUri == linked.owner.profileInfo.uri
|
||||
? linked.owner.accountModel->bestNameForAccount(linked.owner.id)
|
||||
|
@ -2629,7 +2629,7 @@ ConversationModelPimpl::slotMessageReceived(const QString& accountId,
|
|||
// If we're a call in a swarm
|
||||
if (msg.authorUri != linked.owner.profileInfo.uri)
|
||||
updateUnread = true;
|
||||
msg.body = storage::getCallInteractionString(msg);
|
||||
msg.body = storage::getCallInteractionString(msg.authorUri == linked.owner.profileInfo.uri, msg);
|
||||
} else if (msg.type == interaction::Type::CONTACT) {
|
||||
auto bestName = msg.authorUri == linked.owner.profileInfo.uri
|
||||
? linked.owner.accountModel->bestNameForAccount(linked.owner.id)
|
||||
|
@ -3309,7 +3309,7 @@ ConversationModelPimpl::addConversationWith(const QString& convId,
|
|||
} catch (...) {
|
||||
conversation.callId = "";
|
||||
}
|
||||
storage::getHistory(db, conversation);
|
||||
storage::getHistory(db, conversation, linked.owner.profileInfo.uri);
|
||||
std::vector<std::function<void(void)>> updateSlots;
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(interactionsLocks[conversation.uid]);
|
||||
|
@ -3574,7 +3574,7 @@ ConversationModelPimpl::addOrUpdateCallMessage(const QString& callId,
|
|||
// update the db
|
||||
auto msgId = storage::addOrUpdateMessage(db, conv_it->uid, msg, callId);
|
||||
// now set the formatted call message string in memory only
|
||||
msg.body = storage::getCallInteractionString(msg);
|
||||
msg.body = storage::getCallInteractionString(msg.authorUri == linked.owner.profileInfo.uri, msg);
|
||||
bool newInteraction = false;
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(interactionsLocks[conv_it->uid]);
|
||||
|
|
Loading…
Add table
Reference in a new issue