Implement "Add room to group" feature

This commit is contained in:
Luke Barnard 2017-09-26 14:49:13 +01:00
parent b42cf74216
commit ddab8d7b5c
7 changed files with 328 additions and 4 deletions

View file

@ -155,7 +155,7 @@ module.exports = React.createClass({
if (this.props.groupId) {
this._doNaiveGroupRoomSearch(query);
} else {
console.error('Room searching only implemented for groups');
this._doRoomSearch(query);
}
} else {
console.error('Unknown pickerType', this.props.pickerType);
@ -264,6 +264,33 @@ module.exports = React.createClass({
});
},
_doRoomSearch: function(query) {
MatrixClientPeg.get().publicRooms({
filter: {
generic_search_term: query,
},
}).then((resp) => {
const results = [];
resp.chunk.forEach((r) => {
results.push({
room_id: r.room_id,
avatar_url: r.avatar_url,
name: r.name,
});
});
this._processResults(results, query);
}).catch((err) => {
console.error('Error whilst searching public rooms: ', err);
this.setState({
searchError: err.errcode ? err.message : _t('Something went wrong!'),
});
}).done(() => {
this.setState({
busy: false,
});
});
},
_doUserDirectorySearch: function(query) {
this.setState({
busy: true,