Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Merge pull request #4859 from matrix-org/t3chguy/dedup-rooms-autocomp…
Browse files Browse the repository at this point in the history
…lete

De-duplicate rooms from the room autocomplete provider
  • Loading branch information
t3chguy authored Jun 30, 2020
2 parents 2247400 + 7d7bafb commit 52b52df
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/autocomplete/RoomProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ import {MatrixClientPeg} from '../MatrixClientPeg';
import QueryMatcher from './QueryMatcher';
import {PillCompletion} from './Components';
import * as sdk from '../index';
import _sortBy from 'lodash/sortBy';
import {makeRoomPermalink} from "../utils/permalinks/Permalinks";
import {ICompletion, ISelectionRange} from "./Autocompleter";
import { uniqBy, sortBy } from 'lodash';

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

Expand Down Expand Up @@ -91,10 +91,11 @@ export default class RoomProvider extends AutocompleteProvider {
this.matcher.setObjects(matcherObjects);
const matchedString = command[0];
completions = this.matcher.match(matchedString);
completions = _sortBy(completions, [
completions = sortBy(completions, [
(c) => score(matchedString, c.displayedAlias),
(c) => c.displayedAlias.length,
]);
completions = uniqBy(completions, (match) => match.room);
completions = completions.map((room) => {
return {
completion: room.displayedAlias,
Expand Down

0 comments on commit 52b52df

Please sign in to comment.