Skip to content

Commit 7d7bafb

Browse files
committed
De-duplicate rooms from the room autocomplete provider
Signed-off-by: Michael Telatynski <[email protected]>
1 parent bb9ae7b commit 7d7bafb

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/autocomplete/RoomProvider.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ import {MatrixClientPeg} from '../MatrixClientPeg';
2525
import QueryMatcher from './QueryMatcher';
2626
import {PillCompletion} from './Components';
2727
import * as sdk from '../index';
28-
import _sortBy from 'lodash/sortBy';
2928
import {makeRoomPermalink} from "../utils/permalinks/Permalinks";
3029
import {ICompletion, ISelectionRange} from "./Autocompleter";
30+
import { uniqBy, sortBy } from 'lodash';
3131

3232
const ROOM_REGEX = /\B#\S*/g;
3333

@@ -91,10 +91,11 @@ export default class RoomProvider extends AutocompleteProvider {
9191
this.matcher.setObjects(matcherObjects);
9292
const matchedString = command[0];
9393
completions = this.matcher.match(matchedString);
94-
completions = _sortBy(completions, [
94+
completions = sortBy(completions, [
9595
(c) => score(matchedString, c.displayedAlias),
9696
(c) => c.displayedAlias.length,
9797
]);
98+
completions = uniqBy(completions, (match) => match.room);
9899
completions = completions.map((room) => {
99100
return {
100101
completion: room.displayedAlias,

0 commit comments

Comments
 (0)