Merge pull request #3058 from matrix-org/bwindels/redactions-local-echo
Don't show "can't redact" dialog on network error, with redaction having local echo & queuing now.
This commit is contained in:
commit
940b2a7ef2
2 changed files with 22 additions and 9 deletions
|
@ -207,6 +207,8 @@ const TimelinePanel = React.createClass({
|
||||||
MatrixClientPeg.get().on("Room.timeline", this.onRoomTimeline);
|
MatrixClientPeg.get().on("Room.timeline", this.onRoomTimeline);
|
||||||
MatrixClientPeg.get().on("Room.timelineReset", this.onRoomTimelineReset);
|
MatrixClientPeg.get().on("Room.timelineReset", this.onRoomTimelineReset);
|
||||||
MatrixClientPeg.get().on("Room.redaction", this.onRoomRedaction);
|
MatrixClientPeg.get().on("Room.redaction", this.onRoomRedaction);
|
||||||
|
// same event handler as Room.redaction as for both we just do forceUpdate
|
||||||
|
MatrixClientPeg.get().on("Room.redactionCancelled", this.onRoomRedaction);
|
||||||
MatrixClientPeg.get().on("Room.receipt", this.onRoomReceipt);
|
MatrixClientPeg.get().on("Room.receipt", this.onRoomReceipt);
|
||||||
MatrixClientPeg.get().on("Room.localEchoUpdated", this.onLocalEchoUpdated);
|
MatrixClientPeg.get().on("Room.localEchoUpdated", this.onLocalEchoUpdated);
|
||||||
MatrixClientPeg.get().on("Room.accountData", this.onAccountData);
|
MatrixClientPeg.get().on("Room.accountData", this.onAccountData);
|
||||||
|
@ -286,6 +288,7 @@ const TimelinePanel = React.createClass({
|
||||||
client.removeListener("Room.timeline", this.onRoomTimeline);
|
client.removeListener("Room.timeline", this.onRoomTimeline);
|
||||||
client.removeListener("Room.timelineReset", this.onRoomTimelineReset);
|
client.removeListener("Room.timelineReset", this.onRoomTimelineReset);
|
||||||
client.removeListener("Room.redaction", this.onRoomRedaction);
|
client.removeListener("Room.redaction", this.onRoomRedaction);
|
||||||
|
client.removeListener("Room.redactionCancelled", this.onRoomRedaction);
|
||||||
client.removeListener("Room.receipt", this.onRoomReceipt);
|
client.removeListener("Room.receipt", this.onRoomReceipt);
|
||||||
client.removeListener("Room.localEchoUpdated", this.onLocalEchoUpdated);
|
client.removeListener("Room.localEchoUpdated", this.onLocalEchoUpdated);
|
||||||
client.removeListener("Room.accountData", this.onAccountData);
|
client.removeListener("Room.accountData", this.onAccountData);
|
||||||
|
|
|
@ -119,19 +119,29 @@ module.exports = React.createClass({
|
||||||
onRedactClick: function() {
|
onRedactClick: function() {
|
||||||
const ConfirmRedactDialog = sdk.getComponent("dialogs.ConfirmRedactDialog");
|
const ConfirmRedactDialog = sdk.getComponent("dialogs.ConfirmRedactDialog");
|
||||||
Modal.createTrackedDialog('Confirm Redact Dialog', '', ConfirmRedactDialog, {
|
Modal.createTrackedDialog('Confirm Redact Dialog', '', ConfirmRedactDialog, {
|
||||||
onFinished: (proceed) => {
|
onFinished: async (proceed) => {
|
||||||
if (!proceed) return;
|
if (!proceed) return;
|
||||||
|
|
||||||
const cli = MatrixClientPeg.get();
|
const cli = MatrixClientPeg.get();
|
||||||
cli.redactEvent(this.props.mxEvent.getRoomId(), this.props.mxEvent.getId()).catch(function(e) {
|
try {
|
||||||
const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
|
await cli.redactEvent(
|
||||||
// display error message stating you couldn't delete this.
|
this.props.mxEvent.getRoomId(),
|
||||||
|
this.props.mxEvent.getId(),
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
const code = e.errcode || e.statusCode;
|
const code = e.errcode || e.statusCode;
|
||||||
Modal.createTrackedDialog('You cannot delete this message', '', ErrorDialog, {
|
// only show the dialog if failing for something other than a network error
|
||||||
title: _t('Error'),
|
// (e.g. no errcode or statusCode) as in that case the redactions end up in the
|
||||||
description: _t('You cannot delete this message. (%(code)s)', {code}),
|
// detached queue and we show the room status bar to allow retry
|
||||||
});
|
if (typeof code !== "undefined") {
|
||||||
}).done();
|
const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
|
||||||
|
// display error message stating you couldn't delete this.
|
||||||
|
Modal.createTrackedDialog('You cannot delete this message', '', ErrorDialog, {
|
||||||
|
title: _t('Error'),
|
||||||
|
description: _t('You cannot delete this message. (%(code)s)', {code}),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
}, 'mx_Dialog_confirmredact');
|
}, 'mx_Dialog_confirmredact');
|
||||||
this.closeMenu();
|
this.closeMenu();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue