Confirm redactions with a dialog
Closes #277 Closes #1805 Signed-off-by: Keyvan Fatehi <keyvanfatehi@gmail.com>
This commit is contained in:
parent
e3e2e3a56c
commit
a9ed2e20cb
2 changed files with 37 additions and 26 deletions
|
@ -62,19 +62,24 @@ module.exports = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
onRedactClick: function() {
|
onRedactClick: function() {
|
||||||
MatrixClientPeg.get().redactEvent(
|
const ConfirmRedactDialog = sdk.getComponent("dialogs.ConfirmRedactDialog");
|
||||||
this.props.mxEvent.getRoomId(), this.props.mxEvent.getId()
|
Modal.createDialog(ConfirmRedactDialog, {
|
||||||
).done(function() {
|
onFinished: (proceed) => {
|
||||||
// message should disappear by itself
|
if (!proceed) return;
|
||||||
}, function(e) {
|
|
||||||
var ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
|
MatrixClientPeg.get().redactEvent(
|
||||||
// display error message stating you couldn't delete this.
|
this.props.mxEvent.getRoomId(), this.props.mxEvent.getId()
|
||||||
var code = e.errcode || e.statusCode;
|
).catch(function(e) {
|
||||||
Modal.createDialog(ErrorDialog, {
|
var ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
|
||||||
title: "Error",
|
// display error message stating you couldn't delete this.
|
||||||
description: "You cannot delete this message. (" + code + ")"
|
var code = e.errcode || e.statusCode;
|
||||||
});
|
Modal.createDialog(ErrorDialog, {
|
||||||
});
|
title: "Error",
|
||||||
|
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();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -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,19 +64,23 @@ module.exports = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
onRedactClick: function() {
|
onRedactClick: function() {
|
||||||
var self = this;
|
const ConfirmRedactDialog = sdk.getComponent("dialogs.ConfirmRedactDialog");
|
||||||
MatrixClientPeg.get().redactEvent(
|
Modal.createDialog(ConfirmRedactDialog, {
|
||||||
this.props.mxEvent.getRoomId(), this.props.mxEvent.getId()
|
onFinished: (proceed) => {
|
||||||
).done(function() {
|
if (!proceed) return;
|
||||||
if (self.props.onFinished) self.props.onFinished();
|
var self = this;
|
||||||
}, function(e) {
|
MatrixClientPeg.get().redactEvent(
|
||||||
var ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
|
this.props.mxEvent.getRoomId(), this.props.mxEvent.getId()
|
||||||
// display error message stating you couldn't delete this.
|
).catch(function(e) {
|
||||||
var code = e.errcode || e.statusCode;
|
var ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
|
||||||
Modal.createDialog(ErrorDialog, {
|
// display error message stating you couldn't delete this.
|
||||||
title: "Error",
|
var code = e.errcode || e.statusCode;
|
||||||
description: "You cannot delete this image. (" + code + ")"
|
Modal.createDialog(ErrorDialog, {
|
||||||
});
|
title: "Error",
|
||||||
|
description: "You cannot delete this image. (" + code + ")"
|
||||||
|
});
|
||||||
|
}).done();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue