Fix 'Reply' action primary property.
authorCamila <hello@camila.codes>
Thu, 29 Sep 2022 13:14:01 +0000 (15:14 +0200)
committerbackportbot-nextcloud[bot] <backportbot-nextcloud[bot]@users.noreply.github.com>
Tue, 4 Oct 2022 11:49:09 +0000 (11:49 +0000)
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 <hello@camila.codes>
src/gui/tray/activitylistmodel.cpp
src/gui/tray/notificationhandler.cpp
test/testactivitylistmodel.cpp

index 905ebcf4214d0266b0fb5e18d645ca2a6cf04c1b..58ccc96393f3cac89826bb9dc20aab5d04c527f9 100644 (file)
@@ -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;
index 9a9e1893b9e454dbfc702c5c6d55dd6aa05ad056..ae5cd05b67dab7ef51708473eaca6e61db30c6cf 100644 (file)
@@ -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);
         } 
 
         a._status = 0;
index 17c5de729ad79588450f1653f521c0fec17e7a91..419a5727b9c7c5542e0147a9e64ca1891ebe15b2 100644 (file)
@@ -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;