Skip to content
Snippets Groups Projects
Commit 6b0adb70 authored by Page Magnier-Slimani's avatar Page Magnier-Slimani
Browse files

notifications: no longer blank notifications when leaving or joining a group

Fixed the issue of blank notification when leaving a group by updating the
OnNewUnreadNotification function.

GitLab: #1921

Change-Id: I87f4c3828a72c9b504a9a68707d6b257ce00154c
parent 217efe60
Branches
Tags
No related merge requests found
...@@ -171,10 +171,20 @@ ConversationsAdapter::onNewUnreadInteraction(const QString& accountId, ...@@ -171,10 +171,20 @@ ConversationsAdapter::onNewUnreadInteraction(const QString& accountId,
if (interaction.authorUri == accountInfo.profileInfo.uri) if (interaction.authorUri == accountInfo.profileInfo.uri)
return; return;
auto from = accountInfo.contactModel->bestNameForContact(interaction.authorUri); auto from = accountInfo.contactModel->bestNameForContact(interaction.authorUri);
auto body_ = interaction.body; QString displayedString;
if (interaction.type == interaction::Type::DATA_TRANSFER) { // Add special handling for member events
body_ = interaction.commit.value("displayName"); if (interaction.type == interaction::Type::CONTACT) {
auto action = interaction.commit.value("action");
if (action == "join") {
displayedString = tr("%1 has joined the conversation.").arg(from);
} else if (action == "remove") {
displayedString = tr("%1 has left the conversation.").arg(from);
}
} else if (interaction.type == interaction::Type::DATA_TRANSFER) {
displayedString = from + ": " + interaction.commit.value("displayName");
} else {
displayedString = from + ": " + interaction.body;
} }
auto preferences = accountInfo.conversationModel->getConversationPreferences(convUid); auto preferences = accountInfo.conversationModel->getConversationPreferences(convUid);
...@@ -190,7 +200,7 @@ ConversationsAdapter::onNewUnreadInteraction(const QString& accountId, ...@@ -190,7 +200,7 @@ ConversationsAdapter::onNewUnreadInteraction(const QString& accountId,
auto notifId = QString("%1;%2;%3").arg(accountId, convUid, interactionId); auto notifId = QString("%1;%2;%3").arg(accountId, convUid, interactionId);
systemTray_->showNotification(notifId, systemTray_->showNotification(notifId,
tr("%1 received a new message").arg(to), tr("%1 received a new message").arg(to),
from + ": " + body_, displayedString,
SystemTray::NotificationType::CHAT, SystemTray::NotificationType::CHAT,
Utils::QImageToByteArray(contactPhoto)); Utils::QImageToByteArray(contactPhoto));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment