mirror of https://github.com/vector-im/riot-web
Merge remote-tracking branch 'origin/develop' into develop
commit
9149475f1d
|
@ -272,20 +272,27 @@ module.exports = React.createClass({
|
||||||
const topicEvent = room.currentState.getStateEvents('m.room.topic', '');
|
const topicEvent = room.currentState.getStateEvents('m.room.topic', '');
|
||||||
const name = nameEvent ? nameEvent.getContent().name : '';
|
const name = nameEvent ? nameEvent.getContent().name : '';
|
||||||
const canonicalAlias = room.getCanonicalAlias();
|
const canonicalAlias = room.getCanonicalAlias();
|
||||||
|
const aliasEvents = room.currentState.getStateEvents('m.room.aliases');
|
||||||
|
const aliases = aliasEvents.map((ev) => ev.getContent().aliases).reduce((a, b) => {
|
||||||
|
return a.concat(b);
|
||||||
|
}, []);
|
||||||
const topic = topicEvent ? topicEvent.getContent().topic : '';
|
const topic = topicEvent ? topicEvent.getContent().topic : '';
|
||||||
|
|
||||||
const nameMatch = (name || '').toLowerCase().includes(lowerCaseQuery);
|
const nameMatch = (name || '').toLowerCase().includes(lowerCaseQuery);
|
||||||
const aliasMatch = (canonicalAlias || '').toLowerCase().includes(lowerCaseQuery);
|
const aliasMatch = aliases.some((alias) =>
|
||||||
|
(alias || '').toLowerCase().includes(lowerCaseQuery),
|
||||||
|
);
|
||||||
const topicMatch = (topic || '').toLowerCase().includes(lowerCaseQuery);
|
const topicMatch = (topic || '').toLowerCase().includes(lowerCaseQuery);
|
||||||
if (!(nameMatch || topicMatch || aliasMatch)) {
|
if (!(nameMatch || topicMatch || aliasMatch)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const avatarEvent = room.currentState.getStateEvents('m.room.avatar', '');
|
const avatarEvent = room.currentState.getStateEvents('m.room.avatar', '');
|
||||||
const avatarUrl = avatarEvent ? avatarEvent.getContent().url : undefined;
|
const avatarUrl = avatarEvent ? avatarEvent.getContent().url : undefined;
|
||||||
|
|
||||||
results.push({
|
results.push({
|
||||||
room_id: room.roomId,
|
room_id: room.roomId,
|
||||||
avatar_url: avatarUrl,
|
avatar_url: avatarUrl,
|
||||||
name: name || canonicalAlias,
|
name: name || canonicalAlias || aliases[0] || _t('Unnamed Room'),
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
this._processResults(results, query);
|
this._processResults(results, query);
|
||||||
|
|
Loading…
Reference in New Issue