From 7633cc490df3b7984c2c56d113b28abe6c508138 Mon Sep 17 00:00:00 2001 From: Camila Date: Thu, 29 Sep 2022 15:14:01 +0200 Subject: [PATCH] Fix 'Reply' action primary property. Primary is set to true when object type is 'room' or 'chat' and it set to false when object type is 'call'. Signed-off-by: Camila --- src/gui/tray/activitylistmodel.cpp | 6 +----- src/gui/tray/notificationhandler.cpp | 23 ++++++++++++++++------- test/testactivitylistmodel.cpp | 2 +- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/gui/tray/activitylistmodel.cpp b/src/gui/tray/activitylistmodel.cpp index ebcd646e1..de4d79c02 100644 --- a/src/gui/tray/activitylistmodel.cpp +++ b/src/gui/tray/activitylistmodel.cpp @@ -782,11 +782,7 @@ QVariantList ActivityListModel::convertLinksToActionButtons(const Activity &acti } for (const auto &activityLink : activity._links) { - if (activityLink._primary - || activityLink._verb == QStringLiteral("DELETE") - || activityLink._verb == QStringLiteral("WEB")) { - customList << ActivityListModel::convertLinkToActionButton(activityLink); - } + customList << ActivityListModel::convertLinkToActionButton(activityLink); } return customList; diff --git a/src/gui/tray/notificationhandler.cpp b/src/gui/tray/notificationhandler.cpp index 5ab8ea213..02105bf93 100644 --- a/src/gui/tray/notificationhandler.cpp +++ b/src/gui/tray/notificationhandler.cpp @@ -110,27 +110,36 @@ void ServerNotificationHandler::slotNotificationsReceived(const QJsonDocument &j if (a._objectType == "chat" || a._objectType == "call" || a._objectType == "room") { const auto objectId = json.value("object_id").toString(); const auto objectIdData = objectId.split("/"); + + ActivityLink al; + al._label = tr("Reply"); + al._verb = "REPLY"; + al._primary = true; + a._talkNotificationData.conversationToken = objectIdData.first(); + if (a._objectType == "chat" && objectIdData.size() > 1) { a._talkNotificationData.messageId = objectIdData.last(); } else { qCInfo(lcServerNotification) << "Replying directly to Talk conversation" << a._talkNotificationData.conversationToken << "will not be possible because the notification doesn't contain the message ID."; } - ActivityLink al; - al._label = tr("Reply"); - al._verb = "REPLY"; - al._primary = true; - a._links.insert(0, al); + if (a._subjectRichParameters.contains("user")) { + + // callback then it is the primary action + if (a._objectType == "call") { + al._primary = false; + } - if(a._subjectRichParameters.contains("user")) { a._talkNotificationData.userAvatar = ai->account()->url().toString() + QStringLiteral("/index.php/avatar/") + a._subjectRichParameters["user"].id + QStringLiteral("/128"); } // We want to serve incoming call dialogs to the user for calls that - if(a._objectType == "call" && a._dateTime.secsTo(QDateTime::currentDateTime()) < 120) { + if (a._objectType == "call" && a._dateTime.secsTo(QDateTime::currentDateTime()) < 120) { callList.append(a); } + + a._links.insert(al._primary? 0 : a._links.size(), al); } QUrl link(json.value("link").toString()); diff --git a/test/testactivitylistmodel.cpp b/test/testactivitylistmodel.cpp index 16c1267f5..25efb6561 100644 --- a/test/testactivitylistmodel.cpp +++ b/test/testactivitylistmodel.cpp @@ -143,7 +143,7 @@ public: replyAction.insert(QStringLiteral("label"), QStringLiteral("Reply")); replyAction.insert(QStringLiteral("link"), QStringLiteral("")); replyAction.insert(QStringLiteral("type"), QStringLiteral("REPLY")); - replyAction.insert(QStringLiteral("primary"), true); + replyAction.insert(QStringLiteral("primary"), false); actionsArray.push_back(replyAction); QJsonObject primaryAction;