Merge pull request #3470 from kfatehi/277-confirmredact

Confirm redactions with a dialog
This commit is contained in:
Matthew Hodgson 2017-03-19 02:36:01 +00:00 committed by GitHub
commit af122172f1
2 changed files with 37 additions and 26 deletions

View File

@ -62,11 +62,14 @@ module.exports = React.createClass({
}, },
onRedactClick: function() { onRedactClick: function() {
const ConfirmRedactDialog = sdk.getComponent("dialogs.ConfirmRedactDialog");
Modal.createDialog(ConfirmRedactDialog, {
onFinished: (proceed) => {
if (!proceed) return;
MatrixClientPeg.get().redactEvent( MatrixClientPeg.get().redactEvent(
this.props.mxEvent.getRoomId(), this.props.mxEvent.getId() this.props.mxEvent.getRoomId(), this.props.mxEvent.getId()
).done(function() { ).catch(function(e) {
// message should disappear by itself
}, function(e) {
var ErrorDialog = sdk.getComponent("dialogs.ErrorDialog"); var ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
// display error message stating you couldn't delete this. // display error message stating you couldn't delete this.
var code = e.errcode || e.statusCode; var code = e.errcode || e.statusCode;
@ -74,7 +77,9 @@ module.exports = React.createClass({
title: "Error", title: "Error",
description: "You cannot delete this message. (" + code + ")" description: "You cannot delete this message. (" + code + ")"
}); });
}); }).done();
},
}, 'mx_Dialog_confirmredact');
if (this.props.onFinished) this.props.onFinished(); if (this.props.onFinished) this.props.onFinished();
}, },

View File

@ -23,6 +23,8 @@ var MatrixClientPeg = require('matrix-react-sdk/lib/MatrixClientPeg');
var DateUtils = require('matrix-react-sdk/lib/DateUtils'); var DateUtils = require('matrix-react-sdk/lib/DateUtils');
var filesize = require('filesize'); var filesize = require('filesize');
var AccessibleButton = require('matrix-react-sdk/lib/components/views/elements/AccessibleButton'); var AccessibleButton = require('matrix-react-sdk/lib/components/views/elements/AccessibleButton');
const Modal = require('matrix-react-sdk/lib/Modal');
const sdk = require('matrix-react-sdk');
module.exports = React.createClass({ module.exports = React.createClass({
displayName: 'ImageView', displayName: 'ImageView',
@ -62,12 +64,14 @@ module.exports = React.createClass({
}, },
onRedactClick: function() { onRedactClick: function() {
const ConfirmRedactDialog = sdk.getComponent("dialogs.ConfirmRedactDialog");
Modal.createDialog(ConfirmRedactDialog, {
onFinished: (proceed) => {
if (!proceed) return;
var self = this; var self = this;
MatrixClientPeg.get().redactEvent( MatrixClientPeg.get().redactEvent(
this.props.mxEvent.getRoomId(), this.props.mxEvent.getId() this.props.mxEvent.getRoomId(), this.props.mxEvent.getId()
).done(function() { ).catch(function(e) {
if (self.props.onFinished) self.props.onFinished();
}, function(e) {
var ErrorDialog = sdk.getComponent("dialogs.ErrorDialog"); var ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
// display error message stating you couldn't delete this. // display error message stating you couldn't delete this.
var code = e.errcode || e.statusCode; var code = e.errcode || e.statusCode;
@ -75,6 +79,8 @@ module.exports = React.createClass({
title: "Error", title: "Error",
description: "You cannot delete this image. (" + code + ")" description: "You cannot delete this image. (" + code + ")"
}); });
}).done();
}
}); });
}, },