Skip to content

Commit 662942e

Browse files
committed
Use dispatch to change room tags from RoomTileContextMenu
1 parent 83996c0 commit 662942e

File tree

1 file changed

+9
-35
lines changed

1 file changed

+9
-35
lines changed

src/components/views/context_menus/RoomTileContextMenu.js

Lines changed: 9 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -59,42 +59,16 @@ module.exports = React.createClass({
5959
},
6060

6161
_toggleTag: function(tagNameOn, tagNameOff) {
62-
var self = this;
63-
const roomId = this.props.room.roomId;
64-
var cli = MatrixClientPeg.get();
65-
if (!cli.isGuest()) {
66-
Promise.delay(500).then(function() {
67-
if (tagNameOff !== null && tagNameOff !== undefined) {
68-
cli.deleteRoomTag(roomId, tagNameOff).finally(function() {
69-
// Close the context menu
70-
if (self.props.onFinished) {
71-
self.props.onFinished();
72-
};
73-
}).catch(function(err) {
74-
var ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
75-
Modal.createTrackedDialog('Failed to remove tag from room 1', '', ErrorDialog, {
76-
title: _t('Failed to remove tag %(tagName)s from room', {tagName: tagNameOff}),
77-
description: ((err && err.message) ? err.message : _t('Operation failed')),
78-
});
79-
});
80-
}
62+
if (!MatrixClientPeg.get().isGuest()) {
63+
Promise.delay(500).then(() => {
64+
dis.dispatch(RoomListActions.tagRoom(
65+
MatrixClientPeg.get(),
66+
this.props.room,
67+
tagNameOff, tagNameOn,
68+
undefined, 0,
69+
), true);
8170

82-
if (tagNameOn !== null && tagNameOn !== undefined) {
83-
// If the tag ordering meta data is required, it is added by
84-
// the RoomSubList when it sorts its rooms
85-
cli.setRoomTag(roomId, tagNameOn, {}).finally(function() {
86-
// Close the context menu
87-
if (self.props.onFinished) {
88-
self.props.onFinished();
89-
};
90-
}).catch(function(err) {
91-
var ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
92-
Modal.createTrackedDialog('Failed to remove tag from room 2', '', ErrorDialog, {
93-
title: _t('Failed to remove tag %(tagName)s from room', {tagName: tagNameOn}),
94-
description: ((err && err.message) ? err.message : _t('Operation failed')),
95-
});
96-
});
97-
}
71+
this.props.onFinished();
9872
});
9973
}
10074
},

0 commit comments

Comments
 (0)