Skip to content

Commit

Permalink
fix: allow full link search
Browse files Browse the repository at this point in the history
Signed-off-by: Boluwatife Omosowon <boluomosowon@gmail.com>
  • Loading branch information
bolu-tife committed Apr 10, 2022
1 parent 604a6ed commit 9ba6051
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/components/structures/RoomDirectory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,10 @@ export default class RoomDirectory extends React.Component<IProps, IState> {
this.getMoreRooms();
};

private transformSearchTerm(term: string): string {
return term.substring(term.lastIndexOf("#"));
};

private getMoreRooms(): Promise<boolean> {
if (!MatrixClientPeg.get()) return Promise.resolve(false);

Expand All @@ -186,7 +190,7 @@ export default class RoomDirectory extends React.Component<IProps, IState> {
opts.third_party_instance_id = this.state.instanceId as string;
}
if (this.nextBatch) opts.since = this.nextBatch;
if (filterString) opts.filter = { generic_search_term: filterString };
if (filterString) opts.filter = { generic_search_term: this.transformSearchTerm(filterString) };
return MatrixClientPeg.get().publicRooms(opts).then((data) => {
if (
filterString != this.state.filterString ||
Expand Down Expand Up @@ -322,7 +326,7 @@ export default class RoomDirectory extends React.Component<IProps, IState> {

private onFilterChange = (alias: string) => {
this.setState({
filterString: alias?.trim() || "",
filterString: this.transformSearchTerm(alias?.trim()) || "",
});

// don't send the request for a little bit,
Expand Down
6 changes: 5 additions & 1 deletion src/components/structures/RoomSearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,13 @@ export default class RoomSearch extends React.PureComponent<IProps, IState> {
}
};

private transformSearchTerm(term: string): string {
return term.substring(term.lastIndexOf("#"));
};

private onChange = () => {
if (this.elementRef.current?.tagName !== "INPUT") return;
this.setState({ query: (this.elementRef.current as HTMLInputElement).value });
this.setState({ query: this.transformSearchTerm((this.elementRef.current as HTMLInputElement).value) });
};

private onFocus = (ev: React.FocusEvent<HTMLInputElement>) => {
Expand Down

0 comments on commit 9ba6051

Please sign in to comment.