support resending reactions

pull/21833/head
Bruno Windels 2019-07-01 17:39:00 +02:00
parent 8160759a52
commit 0d79b03f53
2 changed files with 31 additions and 0 deletions

View File

@ -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 = (
<div className="mx_MessageContextMenu_field" onClick={this.onResendReactionsClick}>
{ _t('Resend %(unsentCount)s reactions', {unsentCount: unsentReactionsCount}) }
</div>
);
}
if (redactStatus === EventStatus.NOT_SENT) {
resendRedactionButton = (
<div className="mx_MessageContextMenu_field" onClick={this.onResendRedactionClick}>

View File

@ -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",