From a11deffe5ed2eaaac528508df3f2933c0e6623c5 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Tue, 4 Jun 2019 13:10:17 +0200 Subject: [PATCH 1/4] only show "can't redact" dialog when not a network error as the redaction is queued now and might be sent later --- .../views/context_menus/MessageContextMenu.js | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/src/components/views/context_menus/MessageContextMenu.js b/src/components/views/context_menus/MessageContextMenu.js index 2e4611f7d05..b50b7a1f83c 100644 --- a/src/components/views/context_menus/MessageContextMenu.js +++ b/src/components/views/context_menus/MessageContextMenu.js @@ -119,19 +119,28 @@ module.exports = React.createClass({ onRedactClick: function() { const ConfirmRedactDialog = sdk.getComponent("dialogs.ConfirmRedactDialog"); Modal.createTrackedDialog('Confirm Redact Dialog', '', ConfirmRedactDialog, { - onFinished: (proceed) => { + onFinished: async (proceed) => { if (!proceed) return; const cli = MatrixClientPeg.get(); - cli.redactEvent(this.props.mxEvent.getRoomId(), this.props.mxEvent.getId()).catch(function(e) { - const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog"); - // display error message stating you couldn't delete this. + try { + await cli.redactEvent( + this.props.mxEvent.getRoomId(), + this.props.mxEvent.getId(), + ); + } catch (e) { const code = e.errcode || e.statusCode; - Modal.createTrackedDialog('You cannot delete this message', '', ErrorDialog, { - title: _t('Error'), - description: _t('You cannot delete this message. (%(code)s)', {code}), - }); - }).done(); + // only show the dialog if failing for something other than a network error + // (e.g. no errcode or statusCode) + if (typeof code !== "undefined") { + 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'); this.closeMenu(); From 629b7768201014308d5388734ba90aa424efdfc5 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Tue, 4 Jun 2019 16:11:49 +0200 Subject: [PATCH 2/4] clarify why we dont need dialog on network error --- 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 b50b7a1f83c..02caa99295d 100644 --- a/src/components/views/context_menus/MessageContextMenu.js +++ b/src/components/views/context_menus/MessageContextMenu.js @@ -131,7 +131,8 @@ module.exports = React.createClass({ } catch (e) { const code = e.errcode || e.statusCode; // only show the dialog if failing for something other than a network error - // (e.g. no errcode or statusCode) + // (e.g. no errcode or statusCode) as that case the redaction end up in the + // detached queue and we show the room status bar to allow retry if (typeof code !== "undefined") { const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog"); // display error message stating you couldn't delete this. From 62ad40d1d9f5388ce5d5ca7d915814cf88c1a174 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Tue, 4 Jun 2019 14:53:01 +0000 Subject: [PATCH 3/4] spelling Co-Authored-By: J. Ryan Stinnett --- src/components/views/context_menus/MessageContextMenu.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/views/context_menus/MessageContextMenu.js b/src/components/views/context_menus/MessageContextMenu.js index 02caa99295d..95bf59b4706 100644 --- a/src/components/views/context_menus/MessageContextMenu.js +++ b/src/components/views/context_menus/MessageContextMenu.js @@ -131,7 +131,7 @@ module.exports = React.createClass({ } catch (e) { const code = e.errcode || e.statusCode; // only show the dialog if failing for something other than a network error - // (e.g. no errcode or statusCode) as that case the redaction end up in the + // (e.g. no errcode or statusCode) as in that case the redactions end up in the // detached queue and we show the room status bar to allow retry if (typeof code !== "undefined") { const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog"); From ef7b7628acfaa9a52a029ff360c5936b7a73d6ca Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Tue, 4 Jun 2019 18:44:48 +0200 Subject: [PATCH 4/4] use Room.redactionCancelled event --- src/components/structures/TimelinePanel.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/components/structures/TimelinePanel.js b/src/components/structures/TimelinePanel.js index c939d31f94a..178250e7850 100644 --- a/src/components/structures/TimelinePanel.js +++ b/src/components/structures/TimelinePanel.js @@ -207,6 +207,8 @@ const TimelinePanel = React.createClass({ MatrixClientPeg.get().on("Room.timeline", this.onRoomTimeline); MatrixClientPeg.get().on("Room.timelineReset", this.onRoomTimelineReset); 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.localEchoUpdated", this.onLocalEchoUpdated); MatrixClientPeg.get().on("Room.accountData", this.onAccountData); @@ -286,6 +288,7 @@ const TimelinePanel = React.createClass({ client.removeListener("Room.timeline", this.onRoomTimeline); client.removeListener("Room.timelineReset", this.onRoomTimelineReset); client.removeListener("Room.redaction", this.onRoomRedaction); + client.removeListener("Room.redactionCancelled", this.onRoomRedaction); client.removeListener("Room.receipt", this.onRoomReceipt); client.removeListener("Room.localEchoUpdated", this.onLocalEchoUpdated); client.removeListener("Room.accountData", this.onAccountData);