Hide widget panel while it is being deleted.

This commit is contained in:
Richard Lewis 2017-07-13 00:27:03 +01:00
parent 4cc8b5621d
commit 9a1e7ad170

View file

@ -46,6 +46,7 @@ export default React.createClass({
loading: false, loading: false,
widgetUrl: this.props.url, widgetUrl: this.props.url,
error: null, error: null,
deleting: false,
}; };
}, },
@ -92,6 +93,7 @@ export default React.createClass({
_onDeleteClick: function() { _onDeleteClick: function() {
console.log("Delete widget %s", this.props.id); console.log("Delete widget %s", this.props.id);
this.setState({deleting: true});
MatrixClientPeg.get().sendStateEvent( MatrixClientPeg.get().sendStateEvent(
this.props.room.roomId, this.props.room.roomId,
'im.vector.modular.widgets', 'im.vector.modular.widgets',
@ -101,6 +103,7 @@ export default React.createClass({
console.log('Deleted widget'); console.log('Deleted widget');
}, (e) => { }, (e) => {
console.error('Failed to delete widget', e); console.error('Failed to delete widget', e);
this.setState({deleting: false});
}); });
}, },
@ -115,6 +118,12 @@ export default React.createClass({
render: function() { render: function() {
let appTileBody; let appTileBody;
// Don't render widget if it is in the process of being deleted
if (this.state.deleting) {
return <div></div>;
}
if (this.state.loading) { if (this.state.loading) {
appTileBody = ( appTileBody = (
<div> Loading... </div> <div> Loading... </div>