Make "Remove" option conditional in context menu

Refactor code in the backend so things can work
better
This commit is contained in:
vSLG
2020-04-01 14:33:19 -03:00
committed by miruka
parent fc878e7537
commit e60a7f6dac
6 changed files with 69 additions and 34 deletions

View File

@@ -220,16 +220,28 @@ HColumnLayout {
HMenuItemPopupSpawner {
icon.name: "remove-message"
text: qsTr("Remove")
enabled: ! isRedacted
enabled: properties.eventIds.length
popup: "Popups/RedactEvents.qml"
popupParent: chat
properties: ({
userId: chat.userId,
roomId: chat.roomId,
eventIds: eventList.selectedCount ?
eventList.getSortedChecked().map(ev => ev.event_id) :
[model.event_id]
eventIds:
(
eventList.selectedCount ?
eventList.getSortedChecked() :
[model]
).filter(ev =>
(
ev.sender_id === chat.userId ||
chat.roomInfo.can_redact
) && ! isRedacted
).map(ev => ev.event_id),
"details.text":
(! chat.roomInfo.can_redact && eventList.selectedCount) ?
qsTr("Only your messages will be removed") :
""
})
}