Fix 'Reply' action primary property.
authorCamila <hello@camila.codes>
Thu, 29 Sep 2022 13:14:01 +0000 (15:14 +0200)
committerCamila <hello@camila.codes>
Thu, 29 Sep 2022 13:20:56 +0000 (15:20 +0200)
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 ebcd646e1a0c482ef692fe2b6d8331f2d1b2b71b..de4d79c026307707e108cbbcb2ab6adbb85cbc70 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 5ab8ea213f821bcccc114ca208dede26ccc503bb..02105bf934feedaadc2cfa97f930f8382feffca5 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);
         } 
 
         QUrl link(json.value("link").toString());
index 16c1267f50c2dca72274c5d0574052075e5deea5..25efb6561ef00fe8bb8ecb6f4781e3ba18d31a3c 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;