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