Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/desktop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCamila <hello@camila.codes>2022-09-29 22:26:20 +0300
committerCamila (Rebase PR Action) <hello@camila.codes>2022-10-17 14:29:23 +0300
commit0624bec007a14e229e65f2ff4cd4f9a0d7cfcc9b (patch)
treeb71ea0babbbecb30a5f5cb2d980091c28f258542 /src
parent5baa254f3dfe66367d7d08c7fe4e2d257433a9a2 (diff)
Fix the dismiss button: display it whenever possible.
Signed-off-by: Camila <hello@camila.codes>
Diffstat (limited to 'src')
-rw-r--r--src/gui/tray/ActivityItem.qml4
-rw-r--r--src/gui/tray/activitylistmodel.cpp23
-rw-r--r--src/gui/tray/notificationhandler.cpp16
3 files changed, 5 insertions, 38 deletions
diff --git a/src/gui/tray/ActivityItem.qml b/src/gui/tray/ActivityItem.qml
index b067ce8a8..9b67f1e57 100644
--- a/src/gui/tray/ActivityItem.qml
+++ b/src/gui/tray/ActivityItem.qml
@@ -46,7 +46,7 @@ ItemDelegate {
Layout.fillWidth: true
Layout.minimumHeight: Style.minActivityHeight
- showDismissButton: model.links.length > 0 && model.linksForActionButtons.length === 0
+ showDismissButton: model.links.length > 0
activityData: model
@@ -94,7 +94,7 @@ ItemDelegate {
adjustedHeaderColor: root.adjustedHeaderColor
- onTriggerAction: activityModel.slotTriggerAction(model.index, actionIndex)
+ onTriggerAction: activityModel.slotTriggerAction(model.activityIndex, actionIndex)
onShowReplyField: root.isTalkReplyOptionVisible = true
}
}
diff --git a/src/gui/tray/activitylistmodel.cpp b/src/gui/tray/activitylistmodel.cpp
index fc6df208f..8ebdcfef5 100644
--- a/src/gui/tray/activitylistmodel.cpp
+++ b/src/gui/tray/activitylistmodel.cpp
@@ -740,27 +740,10 @@ void ActivityListModel::slotTriggerDismiss(const int activityIndex)
return;
}
- const auto activityLinks = _finalList[activityIndex]._links;
-
- const auto foundActivityLinkIt = std::find_if(std::cbegin(activityLinks), std::cend(activityLinks), [](const ActivityLink &link) {
- return link._verb == QStringLiteral("DELETE");
- });
-
- if (foundActivityLinkIt == std::cend(activityLinks)) {
- qCWarning(lcActivity) << "Couldn't find dismiss action in activity at index" << activityIndex
- << " links.size() " << activityLinks.size();
- return;
- }
-
- const auto actionIndex = static_cast<int>(std::distance(activityLinks.begin(), foundActivityLinkIt));
-
- if (actionIndex < 0 || actionIndex > activityLinks.size()) {
- qCWarning(lcActivity) << "Couldn't find dismiss action in activity at index" << activityIndex
- << " actionIndex found " << actionIndex;
- return;
- }
+ constexpr auto deleteVerb = "DELETE";
+ const auto activity = _finalList[activityIndex];
- slotTriggerAction(activityIndex, actionIndex);
+ emit sendNotificationRequest(activity._accName, Utility::concatUrlPath(accountState()->account()->url(), "ocs/v2.php/apps/notifications/api/v2/notifications/" + QString::number(activity._id)).toString(), deleteVerb, activityIndex);
}
AccountState *ActivityListModel::accountState() const
diff --git a/src/gui/tray/notificationhandler.cpp b/src/gui/tray/notificationhandler.cpp
index 02105bf93..4137cb361 100644
--- a/src/gui/tray/notificationhandler.cpp
+++ b/src/gui/tray/notificationhandler.cpp
@@ -154,22 +154,6 @@ void ServerNotificationHandler::slotNotificationsReceived(const QJsonDocument &j
}
a._link = link;
- // Add another action to dismiss notification on server
- // https://github.com/owncloud/notifications/blob/master/docs/ocs-endpoint-v1.md#deleting-a-notification-for-a-user
- constexpr auto deleteVerb = "DELETE";
- const auto itLink = std::find_if(std::cbegin(a._links), std::cend(a._links), [deleteVerb](const ActivityLink& link) {
- Q_UNUSED(deleteVerb)
- return link._verb == deleteVerb;
- });
- if (itLink == std::cend(a._links)) {
- ActivityLink al;
- al._label = tr("Dismiss");
- al._link = Utility::concatUrlPath(ai->account()->url(), notificationsPath + "/" + QString::number(a._id)).toString();
- al._verb = deleteVerb;
- al._primary = false;
- a._links.append(al);
- }
-
list.append(a);
}
emit newNotificationList(list);