2020-03-27 07:31:57 +11:00
|
|
|
// SPDX-License-Identifier: LGPL-3.0-or-later
|
|
|
|
|
|
|
|
import QtQuick 2.12
|
|
|
|
import QtQuick.Layouts 1.12
|
|
|
|
import "../Base"
|
|
|
|
|
|
|
|
BoxPopup {
|
|
|
|
summary.text:
|
2020-04-03 01:19:43 +11:00
|
|
|
isLast ?
|
|
|
|
qsTr("Remove your last message?") :
|
|
|
|
|
2020-04-03 21:13:45 +11:00
|
|
|
eventSenderAndIds.length > 1 ?
|
|
|
|
qsTr("Remove %1 messages?").arg(eventSenderAndIds.length) :
|
2020-04-03 01:19:43 +11:00
|
|
|
|
|
|
|
qsTr("Remove this message?")
|
2020-03-27 07:31:57 +11:00
|
|
|
|
2020-04-02 04:33:19 +11:00
|
|
|
details.color: theme.colors.warningText
|
2020-04-02 06:15:49 +11:00
|
|
|
details.text:
|
|
|
|
onlyOwnMessageWarning ?
|
2020-04-03 01:19:43 +11:00
|
|
|
qsTr("Only your messages can be removed") :
|
2020-04-02 06:15:49 +11:00
|
|
|
""
|
2020-04-02 04:33:19 +11:00
|
|
|
|
2020-03-27 07:31:57 +11:00
|
|
|
okText: qsTr("Remove")
|
|
|
|
box.focusButton: "ok"
|
|
|
|
|
2020-04-03 21:13:45 +11:00
|
|
|
onOk: {
|
|
|
|
const idsForSender = {} // {senderId: [eventId, ...]}
|
2020-03-27 07:31:57 +11:00
|
|
|
|
2020-04-03 21:13:45 +11:00
|
|
|
for (const [senderId, eventId] of eventSenderAndIds) {
|
|
|
|
if (! idsForSender[senderId])
|
|
|
|
idsForSender[senderId] = []
|
2020-04-03 01:19:43 +11:00
|
|
|
|
2020-04-03 21:13:45 +11:00
|
|
|
idsForSender[senderId].push(eventId)
|
|
|
|
}
|
|
|
|
|
|
|
|
print( JSON.stringify( idsForSender, null, 4))
|
|
|
|
|
|
|
|
for (const [senderId, eventIds] of Object.entries(idsForSender))
|
|
|
|
py.callClientCoro(
|
|
|
|
mainUI.accountIds.includes(senderId) ? senderId : preferUserId,
|
|
|
|
"room_mass_redact",
|
|
|
|
[roomId, reasonField.field.text, ...eventIds]
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
property string preferUserId: ""
|
2020-03-27 07:31:57 +11:00
|
|
|
property string roomId: ""
|
|
|
|
|
2020-04-03 21:13:45 +11:00
|
|
|
property var eventSenderAndIds: [] // [[senderId, eventId], ...]
|
2020-04-02 06:15:49 +11:00
|
|
|
property bool onlyOwnMessageWarning: false
|
2020-04-03 01:19:43 +11:00
|
|
|
property bool isLast: false
|
|
|
|
|
|
|
|
|
|
|
|
HLabeledTextField {
|
|
|
|
id: reasonField
|
|
|
|
label.text: qsTr("Optional reason:")
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
2020-03-27 07:31:57 +11:00
|
|
|
}
|