From 20abb2c2dfd15eb339d9730589cf65fada4299cb Mon Sep 17 00:00:00 2001
From: Michael Telatynski <7t3chguy@gmail.com>
Date: Fri, 21 Apr 2017 13:01:10 +0100
Subject: [PATCH 1/6] Add Forward Message button to m.room.message events
Conform this file to eslint
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
---
.../views/context_menus/MessageContextMenu.js | 64 ++++++++++++-------
1 file changed, 41 insertions(+), 23 deletions(-)
diff --git a/src/components/views/context_menus/MessageContextMenu.js b/src/components/views/context_menus/MessageContextMenu.js
index db416b8a06..4a6c978892 100644
--- a/src/components/views/context_menus/MessageContextMenu.js
+++ b/src/components/views/context_menus/MessageContextMenu.js
@@ -16,13 +16,13 @@ limitations under the License.
'use strict';
-var React = require('react');
+const React = require('react');
-var MatrixClientPeg = require('matrix-react-sdk/lib/MatrixClientPeg');
-var dis = require('matrix-react-sdk/lib/dispatcher');
-var sdk = require('matrix-react-sdk');
-var Modal = require('matrix-react-sdk/lib/Modal');
-var Resend = require("matrix-react-sdk/lib/Resend");
+const MatrixClientPeg = require('matrix-react-sdk/lib/MatrixClientPeg');
+const dis = require('matrix-react-sdk/lib/dispatcher');
+const sdk = require('matrix-react-sdk');
+const Modal = require('matrix-react-sdk/lib/Modal');
+const Resend = require("matrix-react-sdk/lib/Resend");
import * as UserSettingsStore from 'matrix-react-sdk/lib/UserSettingsStore';
module.exports = React.createClass({
@@ -45,7 +45,7 @@ module.exports = React.createClass({
},
onViewSourceClick: function() {
- var ViewSource = sdk.getComponent('structures.ViewSource');
+ const ViewSource = sdk.getComponent('structures.ViewSource');
Modal.createDialog(ViewSource, {
content: this.props.mxEvent.event,
}, 'mx_Dialog_viewsource');
@@ -70,12 +70,12 @@ module.exports = React.createClass({
MatrixClientPeg.get().redactEvent(
this.props.mxEvent.getRoomId(), this.props.mxEvent.getId()
).catch(function(e) {
- var ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
+ const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
// display error message stating you couldn't delete this.
- var code = e.errcode || e.statusCode;
+ const code = e.errcode || e.statusCode;
Modal.createDialog(ErrorDialog, {
title: "Error",
- description: "You cannot delete this message. (" + code + ")"
+ description: "You cannot delete this message. (" + code + ")",
});
}).done();
},
@@ -88,6 +88,14 @@ module.exports = React.createClass({
if (this.props.onFinished) this.props.onFinished();
},
+ onForwardClick: function() {
+ dis.dispatch({
+ action: 'forward_message',
+ content: this.props.mxEvent.getContent(),
+ });
+ this.closeMenu();
+ },
+
closeMenu: function() {
if (this.props.onFinished) this.props.onFinished();
},
@@ -99,7 +107,7 @@ module.exports = React.createClass({
if (this.props.onFinished) this.props.onFinished();
},
- onQuoteClick: function () {
+ onQuoteClick: function() {
console.log(this.props.mxEvent);
dis.dispatch({
action: 'quote',
@@ -108,15 +116,16 @@ module.exports = React.createClass({
},
render: function() {
- var eventStatus = this.props.mxEvent.status;
- var resendButton;
- var viewSourceButton;
- var viewClearSourceButton;
- var redactButton;
- var cancelButton;
- var permalinkButton;
- var unhidePreviewButton;
- var externalURLButton;
+ const eventStatus = this.props.mxEvent.status;
+ let resendButton;
+ let redactButton;
+ let cancelButton;
+ let forwardButton;
+ let viewSourceButton;
+ let viewClearSourceButton;
+ let unhidePreviewButton;
+ let permalinkButton;
+ let externalURLButton;
if (eventStatus === 'not_sent') {
resendButton = (
@@ -142,6 +151,14 @@ module.exports = React.createClass({
);
}
+ if (this.props.mxEvent.getType() === 'm.room.message') {
+ forwardButton = (
+
+ Forward Message
+
+ );
+ }
+
viewSourceButton = (
View Source
@@ -162,7 +179,7 @@ module.exports = React.createClass({
Unhide Preview
- )
+ );
}
}
@@ -185,7 +202,7 @@ module.exports = React.createClass({
externalURLButton = (
Source URL
+ rel="noopener" target="_blank" onClick={ this.closeMenu }>Source URL
);
}
@@ -196,6 +213,7 @@ module.exports = React.createClass({
{resendButton}
{redactButton}
{cancelButton}
+ {forwardButton}
{viewSourceButton}
{viewClearSourceButton}
{unhidePreviewButton}
@@ -204,5 +222,5 @@ module.exports = React.createClass({
{externalURLButton}
);
- }
+ },
});
From 77ce58b59d8e382568cf436f5eeaef56d6a495f6 Mon Sep 17 00:00:00 2001
From: Michael Telatynski <7t3chguy@gmail.com>
Date: Fri, 21 Apr 2017 12:58:43 +0100
Subject: [PATCH 2/6] add .idea to .gitignore so I don't accidentally push my
IDE config
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
---
.gitignore | 1 +
1 file changed, 1 insertion(+)
diff --git a/.gitignore b/.gitignore
index c28df64c65..c9e9b250be 100644
--- a/.gitignore
+++ b/.gitignore
@@ -12,3 +12,4 @@
npm-debug.log
electron/dist
electron/pub
+/.idea
From 92b52a61e71f808a65afc0e4d93aa9a08f5a022b Mon Sep 17 00:00:00 2001
From: Michael Telatynski <7t3chguy@gmail.com>
Date: Mon, 24 Apr 2017 18:33:25 +0100
Subject: [PATCH 3/6] don't show forward option for things we cannot decrypt
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
---
src/components/views/context_menus/MessageContextMenu.js | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/components/views/context_menus/MessageContextMenu.js b/src/components/views/context_menus/MessageContextMenu.js
index 4a6c978892..5de8d18d72 100644
--- a/src/components/views/context_menus/MessageContextMenu.js
+++ b/src/components/views/context_menus/MessageContextMenu.js
@@ -151,7 +151,8 @@ module.exports = React.createClass({
);
}
- if (this.props.mxEvent.getType() === 'm.room.message') {
+ if (this.props.mxEvent.getType() === 'm.room.message'
+ && this.props.mxEvent.getContent().msgtype !== 'm.bad.encrypted') {
forwardButton = (
Forward Message
From 0a1ebc2487cf3f85f017b93f21088215136342a2 Mon Sep 17 00:00:00 2001
From: Michael Telatynski <7t3chguy@gmail.com>
Date: Mon, 24 Apr 2017 22:43:02 +0100
Subject: [PATCH 4/6] Don't show for anything that doesn't have a msgtype and
body otherwise the server will just reject it anyway
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
---
.../views/context_menus/MessageContextMenu.js | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/src/components/views/context_menus/MessageContextMenu.js b/src/components/views/context_menus/MessageContextMenu.js
index 5de8d18d72..002ec5bccc 100644
--- a/src/components/views/context_menus/MessageContextMenu.js
+++ b/src/components/views/context_menus/MessageContextMenu.js
@@ -151,13 +151,17 @@ module.exports = React.createClass({
);
}
- if (this.props.mxEvent.getType() === 'm.room.message'
- && this.props.mxEvent.getContent().msgtype !== 'm.bad.encrypted') {
- forwardButton = (
-
- Forward Message
-
- );
+ if (this.props.mxEvent.getType() === 'm.room.message') {
+ const content = this.props.mxEvent.getContent();
+ if (content.msgtype // truthy check msgtype
+ && content.msgtype !== 'm.bad.encrypted'
+ && content.hasOwnProperty('body')) {
+ forwardButton = (
+
+ Forward Message
+
+ );
+ }
}
viewSourceButton = (
From 7777be89ee0ec9f5e268695fc7d1233b8eb2ab0f Mon Sep 17 00:00:00 2001
From: Michael Telatynski <7t3chguy@gmail.com>
Date: Thu, 18 May 2017 23:53:37 +0100
Subject: [PATCH 5/6] only for finalised events
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
---
src/components/views/context_menus/MessageContextMenu.js | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/src/components/views/context_menus/MessageContextMenu.js b/src/components/views/context_menus/MessageContextMenu.js
index 002ec5bccc..ffedbcad8c 100644
--- a/src/components/views/context_menus/MessageContextMenu.js
+++ b/src/components/views/context_menus/MessageContextMenu.js
@@ -151,11 +151,9 @@ module.exports = React.createClass({
);
}
- if (this.props.mxEvent.getType() === 'm.room.message') {
+ if (!eventStatus && this.props.mxEvent.getType() === 'm.room.message') {
const content = this.props.mxEvent.getContent();
- if (content.msgtype // truthy check msgtype
- && content.msgtype !== 'm.bad.encrypted'
- && content.hasOwnProperty('body')) {
+ if (content.msgtype && content.msgtype !== 'm.bad.encrypted' && content.hasOwnProperty('body')) {
forwardButton = (
Forward Message
From 09f987559b0209956b97f84bb21c857074ec31f0 Mon Sep 17 00:00:00 2001
From: Michael Telatynski <7t3chguy@gmail.com>
Date: Fri, 19 May 2017 01:30:36 +0100
Subject: [PATCH 6/6] rename action, now forwarding any event is possible,
limited by where button is shown, i.e easy to modify
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
---
src/components/views/context_menus/MessageContextMenu.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/components/views/context_menus/MessageContextMenu.js b/src/components/views/context_menus/MessageContextMenu.js
index ffedbcad8c..5f8cf6880b 100644
--- a/src/components/views/context_menus/MessageContextMenu.js
+++ b/src/components/views/context_menus/MessageContextMenu.js
@@ -90,8 +90,8 @@ module.exports = React.createClass({
onForwardClick: function() {
dis.dispatch({
- action: 'forward_message',
- content: this.props.mxEvent.getContent(),
+ action: 'forward_event',
+ content: this.props.mxEvent,
});
this.closeMenu();
},