mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 19:08:58 +03:00
Fix UI allowing edits of foreign messages in some cases
This commit is contained in:
parent
4a5b5f992d
commit
a62276c289
6 changed files with 20 additions and 12 deletions
|
@ -165,7 +165,7 @@ Rectangle {
|
|||
event.accepted = true;
|
||||
} else if (event.key == Qt.Key_Space) {
|
||||
// close popup if user enters space after colon
|
||||
if(cursorPosition == completerTriggeredAt + 1)
|
||||
if (cursorPosition == completerTriggeredAt + 1)
|
||||
popup.close();
|
||||
|
||||
if (popup.opened && popup.count <= 0)
|
||||
|
@ -310,7 +310,7 @@ Rectangle {
|
|||
ToolTip.text: qsTr("Emoji")
|
||||
onClicked: emojiPopup.visible ? emojiPopup.close() : emojiPopup.show(emojiButton, function(emoji) {
|
||||
messageInput.insert(messageInput.cursorPosition, emoji);
|
||||
TimelineManager.focusMessageInput()
|
||||
TimelineManager.focusMessageInput();
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -73,7 +73,9 @@ ListView {
|
|||
|
||||
Shortcut {
|
||||
sequence: "Ctrl+E"
|
||||
onActivated: chat.model.edit = chat.model.reply
|
||||
onActivated: {
|
||||
chat.model.edit = chat.model.reply;
|
||||
}
|
||||
}
|
||||
|
||||
Component {
|
||||
|
|
|
@ -26,12 +26,12 @@ Item {
|
|||
acceptedButtons: Qt.AllButtons
|
||||
onClicked: {
|
||||
if (mouse.button === Qt.RightButton)
|
||||
messageContextMenu.show(model.id, model.type, model.isEncrypted, row);
|
||||
messageContextMenu.show(model.id, model.type, model.isEncrypted, model.isEditable, row);
|
||||
else
|
||||
mouse.accepted = false;
|
||||
}
|
||||
onPressAndHold: {
|
||||
messageContextMenu.show(model.id, model.type, model.isEncrypted, row, mapToItem(timelineRoot, mouse.x, mouse.y));
|
||||
messageContextMenu.show(model.id, model.type, model.isEncrypted, model.isEditable, row, mapToItem(timelineRoot, mouse.x, mouse.y));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -143,7 +143,7 @@ Item {
|
|||
image: ":/icons/icons/ui/vertical-ellipsis.png"
|
||||
ToolTip.visible: hovered
|
||||
ToolTip.text: qsTr("Options")
|
||||
onClicked: messageContextMenu.show(model.id, model.type, model.isEncrypted, optionsButton)
|
||||
onClicked: messageContextMenu.show(model.id, model.type, model.isEncrypted, model.isEditable, optionsButton)
|
||||
}
|
||||
|
||||
Label {
|
||||
|
|
|
@ -66,11 +66,13 @@ Page {
|
|||
property string eventId
|
||||
property int eventType
|
||||
property bool isEncrypted
|
||||
property bool isEditable
|
||||
|
||||
function show(eventId_, eventType_, isEncrypted_, showAt_, position) {
|
||||
function show(eventId_, eventType_, isEncrypted_, isEditable_, showAt_, position) {
|
||||
eventId = eventId_;
|
||||
eventType = eventType_;
|
||||
isEncrypted = isEncrypted_;
|
||||
isEditable = isEditable_;
|
||||
if (position)
|
||||
popup(position, showAt_);
|
||||
else
|
||||
|
@ -92,6 +94,8 @@ Page {
|
|||
}
|
||||
|
||||
MenuItem {
|
||||
visible: messageContextMenu.isEditable
|
||||
height: visible ? implicitHeight : 0
|
||||
text: qsTr("Edit")
|
||||
onClicked: TimelineManager.timeline.editAction(messageContextMenu.eventId)
|
||||
}
|
||||
|
|
|
@ -14,6 +14,6 @@ ImageButton {
|
|||
image: ":/icons/icons/ui/smile.png"
|
||||
onClicked: emojiPicker.visible ? emojiPicker.close() : emojiPicker.show(emojiButton, function(emoji) {
|
||||
TimelineManager.queueReactionMessage(event_id, emoji);
|
||||
TimelineManager.focusMessageInput()
|
||||
TimelineManager.focusMessageInput();
|
||||
})
|
||||
}
|
||||
|
|
|
@ -1537,11 +1537,11 @@ void
|
|||
TimelineModel::setEdit(QString newEdit)
|
||||
{
|
||||
if (edit_ != newEdit) {
|
||||
auto ev = events.get(newEdit.toStdString(), "");
|
||||
if (ev && mtx::accessors::sender(*ev) == http::client()->user_id().to_string()) {
|
||||
edit_ = newEdit;
|
||||
emit editChanged(edit_);
|
||||
|
||||
auto ev = events.get(newEdit.toStdString(), "");
|
||||
if (ev) {
|
||||
setReply(QString::fromStdString(
|
||||
mtx::accessors::relations(*ev).reply_to().value_or("")));
|
||||
|
||||
|
@ -1555,6 +1555,8 @@ TimelineModel::setEdit(QString newEdit)
|
|||
input()->setText("");
|
||||
}
|
||||
} else {
|
||||
edit_ = "";
|
||||
emit editChanged(edit_);
|
||||
input()->setText("");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue