From 0d79b03f537855c026b5fb0eff70d4a119457552 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Mon, 1 Jul 2019 17:39:00 +0200 Subject: [PATCH] support resending reactions --- .../views/context_menus/MessageContextMenu.js | 30 +++++++++++++++++++ src/i18n/strings/en_EN.json | 1 + 2 files changed, 31 insertions(+) diff --git a/src/components/views/context_menus/MessageContextMenu.js b/src/components/views/context_menus/MessageContextMenu.js index fd99ed5f6b..4fe4304257 100644 --- a/src/components/views/context_menus/MessageContextMenu.js +++ b/src/components/views/context_menus/MessageContextMenu.js @@ -100,6 +100,13 @@ module.exports = React.createClass({ this.closeMenu(); }, + onResendReactionsClick: function() { + for (const reaction of this._getUnsentReactions()) { + Resend.resend(reaction); + } + this.closeMenu(); + }, + e2eInfoClicked: function() { this.props.e2eInfoCallback(); this.closeMenu(); @@ -227,13 +234,28 @@ module.exports = React.createClass({ this.closeMenu(); }, + _getUnsentReactions() { + const cli = MatrixClientPeg.get(); + const room = cli.getRoom(this.props.mxEvent.getRoomId()); + const eventId = this.props.mxEvent.getId(); + return room.getPendingEvents().filter(e => { + const relation = e.getRelation(); + return relation && + relation.rel_type === "m.annotation" && + relation.event_id === eventId && + e.status === EventStatus.NOT_SENT; + }); + }, + render: function() { const mxEvent = this.props.mxEvent; const eventStatus = mxEvent.status; const editStatus = mxEvent.replacingEvent() && mxEvent.replacingEvent().status; const redactStatus = mxEvent.localRedactionEvent() && mxEvent.localRedactionEvent().status; + const unsentReactionsCount = this._getUnsentReactions().length; let resendButton; let resendEditButton; + let resendReactionsButton; let resendRedactionButton; let redactButton; let cancelButton; @@ -264,6 +286,14 @@ module.exports = React.createClass({ ); } + if (unsentReactionsCount !== 0) { + resendReactionsButton = ( +
+ { _t('Resend %(unsentCount)s reactions', {unsentCount: unsentReactionsCount}) } +
+ ); + } + if (redactStatus === EventStatus.NOT_SENT) { resendRedactionButton = (
diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index b68e72ed1e..8ebd1a0792 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -1303,6 +1303,7 @@ "You cannot delete this message. (%(code)s)": "You cannot delete this message. (%(code)s)", "Resend": "Resend", "Resend edit": "Resend edit", + "Resend %(unsentCount)s reactions": "Resend %(unsentCount)s reactions", "Resend removal": "Resend removal", "Cancel Sending": "Cancel Sending", "Forward Message": "Forward Message",