From 6b0adb7005086a36f981942318ed48897ce28082 Mon Sep 17 00:00:00 2001 From: pmagnier-slimani <page.magnier-slimani@savoirfairelinux.com> Date: Thu, 20 Feb 2025 15:30:21 -0500 Subject: [PATCH] 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 --- src/app/conversationsadapter.cpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/app/conversationsadapter.cpp b/src/app/conversationsadapter.cpp index 5fb5b3a7..45a2f4d9 100644 --- a/src/app/conversationsadapter.cpp +++ b/src/app/conversationsadapter.cpp @@ -171,10 +171,20 @@ ConversationsAdapter::onNewUnreadInteraction(const QString& accountId, if (interaction.authorUri == accountInfo.profileInfo.uri) return; auto from = accountInfo.contactModel->bestNameForContact(interaction.authorUri); - auto body_ = interaction.body; - - if (interaction.type == interaction::Type::DATA_TRANSFER) { - body_ = interaction.commit.value("displayName"); + QString displayedString; + + // Add special handling for member events + 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); @@ -190,7 +200,7 @@ ConversationsAdapter::onNewUnreadInteraction(const QString& accountId, auto notifId = QString("%1;%2;%3").arg(accountId, convUid, interactionId); systemTray_->showNotification(notifId, tr("%1 received a new message").arg(to), - from + ": " + body_, + displayedString, SystemTray::NotificationType::CHAT, Utils::QImageToByteArray(contactPhoto)); -- GitLab