summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--resources/qml/MessageInput.qml4
-rw-r--r--resources/qml/MessageView.qml4
-rw-r--r--resources/qml/TimelineRow.qml6
-rw-r--r--resources/qml/TimelineView.qml6
-rw-r--r--resources/qml/emoji/EmojiButton.qml2
-rw-r--r--src/timeline/TimelineModel.cpp10
6 files changed, 20 insertions, 12 deletions
diff --git a/resources/qml/MessageInput.qml b/resources/qml/MessageInput.qml
index 1b40931f..b5c96660 100644
--- a/resources/qml/MessageInput.qml
+++ b/resources/qml/MessageInput.qml
@@ -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();
             })
         }
 
diff --git a/resources/qml/MessageView.qml b/resources/qml/MessageView.qml
index 0f058830..50e051ab 100644
--- a/resources/qml/MessageView.qml
+++ b/resources/qml/MessageView.qml
@@ -73,7 +73,9 @@ ListView {
 
     Shortcut {
         sequence: "Ctrl+E"
-        onActivated: chat.model.edit = chat.model.reply
+        onActivated: {
+            chat.model.edit = chat.model.reply;
+        }
     }
 
     Component {
diff --git a/resources/qml/TimelineRow.qml b/resources/qml/TimelineRow.qml
index 9f054b9b..5ec23d62 100644
--- a/resources/qml/TimelineRow.qml
+++ b/resources/qml/TimelineRow.qml
@@ -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 {
diff --git a/resources/qml/TimelineView.qml b/resources/qml/TimelineView.qml
index 4b3c006a..b0880493 100644
--- a/resources/qml/TimelineView.qml
+++ b/resources/qml/TimelineView.qml
@@ -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)
         }
diff --git a/resources/qml/emoji/EmojiButton.qml b/resources/qml/emoji/EmojiButton.qml
index 622f8aa2..dd7530a6 100644
--- a/resources/qml/emoji/EmojiButton.qml
+++ b/resources/qml/emoji/EmojiButton.qml
@@ -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();
     })
 }
diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp
index 1163d931..493f755b 100644
--- a/src/timeline/TimelineModel.cpp
+++ b/src/timeline/TimelineModel.cpp
@@ -1537,11 +1537,11 @@ void
 TimelineModel::setEdit(QString newEdit)
 {
         if (edit_ != newEdit) {
-                edit_ = newEdit;
-                emit editChanged(edit_);
-
                 auto ev = events.get(newEdit.toStdString(), "");
-                if (ev) {
+                if (ev && mtx::accessors::sender(*ev) == http::client()->user_id().to_string()) {
+                        edit_ = newEdit;
+                        emit editChanged(edit_);
+
                         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("");
                 }
         }