mirror of https://github.com/vector-im/riot-web
Filter out upgraded rooms from autocomplete results
Fixes https://github.com/vector-im/riot-web/issues/9289 Theory is that this shouldn't happen in the first place (aliases should be transferred), but there's evidently some cases where this doesn't work, or gets state reset.pull/21833/head
parent
db834b315a
commit
340c24cfa7
|
@ -56,7 +56,7 @@ export default class RoomProvider extends AutocompleteProvider {
|
||||||
const {command, range} = this.getCurrentCommand(query, selection, force);
|
const {command, range} = this.getCurrentCommand(query, selection, force);
|
||||||
if (command) {
|
if (command) {
|
||||||
// the only reason we need to do this is because Fuse only matches on properties
|
// the only reason we need to do this is because Fuse only matches on properties
|
||||||
this.matcher.setObjects(client.getRooms().filter(
|
let matcherObjects = client.getRooms().filter(
|
||||||
(room) => !!room && !!getDisplayAliasForRoom(room),
|
(room) => !!room && !!getDisplayAliasForRoom(room),
|
||||||
).map((room) => {
|
).map((room) => {
|
||||||
return {
|
return {
|
||||||
|
@ -64,7 +64,23 @@ export default class RoomProvider extends AutocompleteProvider {
|
||||||
name: room.name,
|
name: room.name,
|
||||||
displayedAlias: getDisplayAliasForRoom(room),
|
displayedAlias: getDisplayAliasForRoom(room),
|
||||||
};
|
};
|
||||||
}));
|
});
|
||||||
|
|
||||||
|
// Filter out any matches where the user will have also autocompleted new rooms
|
||||||
|
matcherObjects = matcherObjects.filter((r) => {
|
||||||
|
const tombstone = r.room.currentState.getStateEvents("m.room.tombstone", "");
|
||||||
|
if (tombstone && tombstone.getContent() && tombstone.getContent()['replacement_room']) {
|
||||||
|
console.log(r.displayedAlias);
|
||||||
|
const hasReplacementRoom = matcherObjects.some(
|
||||||
|
(r2) => r2.room.roomId === tombstone.getContent()['replacement_room'],
|
||||||
|
);
|
||||||
|
console.log(hasReplacementRoom);
|
||||||
|
return !hasReplacementRoom;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
|
this.matcher.setObjects(matcherObjects);
|
||||||
const matchedString = command[0];
|
const matchedString = command[0];
|
||||||
completions = this.matcher.match(matchedString);
|
completions = this.matcher.match(matchedString);
|
||||||
completions = _sortBy(completions, [
|
completions = _sortBy(completions, [
|
||||||
|
|
Loading…
Reference in New Issue