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

Commit 9ba6051

Browse files
committed
fix: allow full link search
Signed-off-by: Boluwatife Omosowon <[email protected]>
1 parent 604a6ed commit 9ba6051

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/components/structures/RoomDirectory.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,10 @@ export default class RoomDirectory extends React.Component<IProps, IState> {
164164
this.getMoreRooms();
165165
};
166166

167+
private transformSearchTerm(term: string): string {
168+
return term.substring(term.lastIndexOf("#"));
169+
};
170+
167171
private getMoreRooms(): Promise<boolean> {
168172
if (!MatrixClientPeg.get()) return Promise.resolve(false);
169173

@@ -186,7 +190,7 @@ export default class RoomDirectory extends React.Component<IProps, IState> {
186190
opts.third_party_instance_id = this.state.instanceId as string;
187191
}
188192
if (this.nextBatch) opts.since = this.nextBatch;
189-
if (filterString) opts.filter = { generic_search_term: filterString };
193+
if (filterString) opts.filter = { generic_search_term: this.transformSearchTerm(filterString) };
190194
return MatrixClientPeg.get().publicRooms(opts).then((data) => {
191195
if (
192196
filterString != this.state.filterString ||
@@ -322,7 +326,7 @@ export default class RoomDirectory extends React.Component<IProps, IState> {
322326

323327
private onFilterChange = (alias: string) => {
324328
this.setState({
325-
filterString: alias?.trim() || "",
329+
filterString: this.transformSearchTerm(alias?.trim()) || "",
326330
});
327331

328332
// don't send the request for a little bit,

src/components/structures/RoomSearch.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,13 @@ export default class RoomSearch extends React.PureComponent<IProps, IState> {
134134
}
135135
};
136136

137+
private transformSearchTerm(term: string): string {
138+
return term.substring(term.lastIndexOf("#"));
139+
};
140+
137141
private onChange = () => {
138142
if (this.elementRef.current?.tagName !== "INPUT") return;
139-
this.setState({ query: (this.elementRef.current as HTMLInputElement).value });
143+
this.setState({ query: this.transformSearchTerm((this.elementRef.current as HTMLInputElement).value) });
140144
};
141145

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

0 commit comments

Comments
 (0)