Use dispatch to change room tags from RoomTileContextMenu
This commit is contained in:
parent
83996c09d9
commit
662942ec29
1 changed files with 9 additions and 35 deletions
|
@ -59,42 +59,16 @@ module.exports = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
_toggleTag: function(tagNameOn, tagNameOff) {
|
_toggleTag: function(tagNameOn, tagNameOff) {
|
||||||
var self = this;
|
if (!MatrixClientPeg.get().isGuest()) {
|
||||||
const roomId = this.props.room.roomId;
|
Promise.delay(500).then(() => {
|
||||||
var cli = MatrixClientPeg.get();
|
dis.dispatch(RoomListActions.tagRoom(
|
||||||
if (!cli.isGuest()) {
|
MatrixClientPeg.get(),
|
||||||
Promise.delay(500).then(function() {
|
this.props.room,
|
||||||
if (tagNameOff !== null && tagNameOff !== undefined) {
|
tagNameOff, tagNameOn,
|
||||||
cli.deleteRoomTag(roomId, tagNameOff).finally(function() {
|
undefined, 0,
|
||||||
// Close the context menu
|
), true);
|
||||||
if (self.props.onFinished) {
|
|
||||||
self.props.onFinished();
|
|
||||||
};
|
|
||||||
}).catch(function(err) {
|
|
||||||
var ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
|
|
||||||
Modal.createTrackedDialog('Failed to remove tag from room 1', '', ErrorDialog, {
|
|
||||||
title: _t('Failed to remove tag %(tagName)s from room', {tagName: tagNameOff}),
|
|
||||||
description: ((err && err.message) ? err.message : _t('Operation failed')),
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tagNameOn !== null && tagNameOn !== undefined) {
|
this.props.onFinished();
|
||||||
// If the tag ordering meta data is required, it is added by
|
|
||||||
// the RoomSubList when it sorts its rooms
|
|
||||||
cli.setRoomTag(roomId, tagNameOn, {}).finally(function() {
|
|
||||||
// Close the context menu
|
|
||||||
if (self.props.onFinished) {
|
|
||||||
self.props.onFinished();
|
|
||||||
};
|
|
||||||
}).catch(function(err) {
|
|
||||||
var ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
|
|
||||||
Modal.createTrackedDialog('Failed to remove tag from room 2', '', ErrorDialog, {
|
|
||||||
title: _t('Failed to remove tag %(tagName)s from room', {tagName: tagNameOn}),
|
|
||||||
description: ((err && err.message) ? err.message : _t('Operation failed')),
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue