Skip to content

Commit

Permalink
fix matrix search link
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 97bcf1d commit 604a6ed
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 14 deletions.
11 changes: 2 additions & 9 deletions src/components/structures/RoomDirectory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ import { Action } from "../../dispatcher/actions";
import PosthogTrackers from "../../PosthogTrackers";
import { ViewRoomPayload } from "../../dispatcher/payloads/ViewRoomPayload";
import { PublicRoomTile } from "../views/rooms/PublicRoomTile";
import { filter } from "jszip";

const LAST_SERVER_KEY = "mx_last_room_directory_server";
const LAST_INSTANCE_KEY = "mx_last_room_directory_instance";
Expand Down Expand Up @@ -165,10 +164,6 @@ 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 @@ -191,7 +186,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: this.transformSearchTerm(filterString) };
if (filterString) opts.filter = { generic_search_term: filterString };
return MatrixClientPeg.get().publicRooms(opts).then((data) => {
if (
filterString != this.state.filterString ||
Expand All @@ -208,10 +203,8 @@ export default class RoomDirectory extends React.Component<IProps, IState> {
return false;
}


this.nextBatch = data.next_batch;
this.setState((s) => ({

...s,
publicRooms: [...s.publicRooms, ...(data.chunk || [])],
loading: false,
Expand Down Expand Up @@ -329,7 +322,7 @@ export default class RoomDirectory extends React.Component<IProps, IState> {

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

// don't send the request for a little bit,
Expand Down
6 changes: 1 addition & 5 deletions src/components/structures/RoomSearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,9 @@ 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.transformSearchTerm((this.elementRef.current as HTMLInputElement).value) });
this.setState({ query: (this.elementRef.current as HTMLInputElement).value });
};

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

0 comments on commit 604a6ed

Please sign in to comment.