Allow adding a reason for deleting messages
BUG: 458911
This commit is contained in:
@@ -864,9 +864,9 @@ QString NeoChatRoom::htmlSafeDisplayName() const
|
||||
return displayName().toHtmlEscaped();
|
||||
}
|
||||
|
||||
void NeoChatRoom::deleteMessagesByUser(const QString &user)
|
||||
void NeoChatRoom::deleteMessagesByUser(const QString &user, const QString &reason)
|
||||
{
|
||||
doDeleteMessagesByUser(user);
|
||||
doDeleteMessagesByUser(user, reason);
|
||||
}
|
||||
|
||||
QString NeoChatRoom::joinRule() const
|
||||
@@ -888,7 +888,7 @@ void NeoChatRoom::setJoinRule(const QString &joinRule)
|
||||
// Not emitting joinRuleChanged() here, since that would override the change in the UI with the *current* value, which is not the *new* value.
|
||||
}
|
||||
|
||||
QCoro::Task<void> NeoChatRoom::doDeleteMessagesByUser(const QString &user)
|
||||
QCoro::Task<void> NeoChatRoom::doDeleteMessagesByUser(const QString &user, QString reason)
|
||||
{
|
||||
QStringList events;
|
||||
for (const auto &event : messageEvents()) {
|
||||
@@ -897,7 +897,7 @@ QCoro::Task<void> NeoChatRoom::doDeleteMessagesByUser(const QString &user)
|
||||
}
|
||||
}
|
||||
for (const auto &e : events) {
|
||||
auto job = connection()->callApi<RedactEventJob>(id(), QUrl::toPercentEncoding(e), connection()->generateTxnId());
|
||||
auto job = connection()->callApi<RedactEventJob>(id(), QUrl::toPercentEncoding(e), connection()->generateTxnId(), reason);
|
||||
co_await qCoro(job, &BaseJob::finished);
|
||||
if (job->error() != BaseJob::Success) {
|
||||
qWarning() << "Error: \"" << job->error() << "\" while deleting messages. Aborting";
|
||||
|
||||
@@ -221,7 +221,7 @@ private:
|
||||
void onAddHistoricalTimelineEvents(rev_iter_t from) override;
|
||||
void onRedaction(const Quotient::RoomEvent &prevEvent, const Quotient::RoomEvent &after) override;
|
||||
|
||||
QCoro::Task<void> doDeleteMessagesByUser(const QString &user);
|
||||
QCoro::Task<void> doDeleteMessagesByUser(const QString &user, QString reason);
|
||||
QCoro::Task<void> doUploadFile(QUrl url, QString body = QString());
|
||||
|
||||
QString m_chatBoxText;
|
||||
@@ -279,5 +279,5 @@ public Q_SLOTS:
|
||||
void addLocalAlias(const QString &alias);
|
||||
void removeLocalAlias(const QString &alias);
|
||||
void toggleReaction(const QString &eventId, const QString &reaction);
|
||||
void deleteMessagesByUser(const QString &user);
|
||||
void deleteMessagesByUser(const QString &user, const QString &reason);
|
||||
};
|
||||
|
||||
@@ -134,11 +134,15 @@ Kirigami.OverlaySheet {
|
||||
visible: user === room.localUser || room.canSendState("redact")
|
||||
|
||||
action: Kirigami.Action {
|
||||
text: i18n("Delete recent messages by this user")
|
||||
text: i18n("Remove recent messages by this user")
|
||||
icon.name: "delete"
|
||||
icon.color: Kirigami.Theme.negativeTextColor
|
||||
onTriggered: {
|
||||
room.deleteMessagesByUser(user.id)
|
||||
applicationWindow().pageStack.pushDialogLayer("qrc:/RemoveSheet.qml", {room: root.room, userId: user.id}, {
|
||||
title: i18nc("@title", "Remove Messages"),
|
||||
width: Kirigami.Units.gridUnit * 25
|
||||
})
|
||||
root.close()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,10 +60,10 @@ MessageDelegateContextMenu {
|
||||
text: i18n("Remove")
|
||||
icon.name: "edit-delete-remove"
|
||||
icon.color: "red"
|
||||
onTriggered: {
|
||||
currentRoom.redactEvent(eventId);
|
||||
root.closeFullscreen()
|
||||
}
|
||||
onTriggered: applicationWindow().pageStack.pushDialogLayer("qrc:/RemoveSheet.qml", {room: currentRoom, eventId: eventId}, {
|
||||
title: i18nc("@title", "Remove Message"),
|
||||
width: Kirigami.Units.gridUnit * 25
|
||||
})
|
||||
},
|
||||
Kirigami.Action {
|
||||
text: i18nc("@action:button 'Report' as in 'Report this event to the administrators'", "Report")
|
||||
|
||||
@@ -46,7 +46,10 @@ Loader {
|
||||
text: i18n("Remove")
|
||||
icon.name: "edit-delete-remove"
|
||||
icon.color: "red"
|
||||
onTriggered: currentRoom.redactEvent(eventId);
|
||||
onTriggered: applicationWindow().pageStack.pushDialogLayer("qrc:/RemoveSheet.qml", {room: currentRoom, eventId: eventId}, {
|
||||
title: i18nc("@title", "Remove Message"),
|
||||
width: Kirigami.Units.gridUnit * 25
|
||||
})
|
||||
},
|
||||
Kirigami.Action {
|
||||
text: i18n("Copy")
|
||||
|
||||
53
src/qml/Menu/Timeline/RemoveSheet.qml
Normal file
53
src/qml/Menu/Timeline/RemoveSheet.qml
Normal file
@@ -0,0 +1,53 @@
|
||||
// SPDX-FileCopyrightText: 2022 Tobias Fella <fella@posteo.de>
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
import QtQuick 2.15
|
||||
import QtQuick.Controls 2.15 as QQC2
|
||||
import QtQuick.Layouts 1.15
|
||||
|
||||
import org.kde.kirigami 2.20 as Kirigami
|
||||
|
||||
Kirigami.Page {
|
||||
id: deleteSheet
|
||||
|
||||
property var room
|
||||
property string eventId
|
||||
|
||||
property string userId: ""
|
||||
|
||||
title: userId.length > 0 ? i18n("Remove Messages") : i18n("Remove Message")
|
||||
|
||||
QQC2.TextArea {
|
||||
id: reason
|
||||
placeholderText: userId.length > 0 ? i18n("Reason for removing this user's recent messages") : i18n("Reason for removing this message")
|
||||
anchors.fill: parent
|
||||
wrapMode: TextEdit.Wrap
|
||||
}
|
||||
|
||||
footer: QQC2.ToolBar {
|
||||
QQC2.DialogButtonBox {
|
||||
anchors.fill: parent
|
||||
Item {
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
QQC2.Button {
|
||||
text: i18nc("@action:button 'Remove' as in 'Remove this message'", "Remove")
|
||||
icon.name: "delete"
|
||||
QQC2.DialogButtonBox.buttonRole: QQC2.DialogButtonBox.AcceptRole
|
||||
onClicked: {
|
||||
if (deleteSheet.userId.length > 0) {
|
||||
deleteSheet.room.deleteMessagesByUser(deleteSheet.userId, reason.text)
|
||||
} else {
|
||||
deleteSheet.room.redactEvent(deleteSheet.eventId, reason.text);
|
||||
}
|
||||
deleteSheet.closeDialog()
|
||||
}
|
||||
}
|
||||
QQC2.Button {
|
||||
text: i18nc("@action", "Cancel")
|
||||
QQC2.DialogButtonBox.buttonRole: QQC2.DialogButtonBox.RejectRole
|
||||
onClicked: deleteSheet.closeDialog()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -91,5 +91,6 @@
|
||||
<file alias="NetworkProxyPage.qml">qml/Settings/NetworkProxyPage.qml</file>
|
||||
<file alias="DevtoolsPage.qml">qml/Page/DevtoolsPage.qml</file>
|
||||
<file alias="ConfirmEncryptionDialog.qml">qml/Dialog/ConfirmEncryptionDialog.qml</file>
|
||||
<file alias="RemoveSheet.qml">qml/Menu/Timeline/RemoveSheet.qml</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
||||
Reference in New Issue
Block a user