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

Allows search to recognize full room links #8275

Merged
merged 33 commits into from
May 9, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
97bcf1d
fix matrix search link
bolu-tife Apr 10, 2022
604a6ed
fix matrix search link
bolu-tife Apr 10, 2022
9ba6051
fix: allow full link search
bolu-tife Apr 10, 2022
9d10d95
fix: allow full link search on new search feature
bolu-tife Apr 10, 2022
85c9d66
improve transformSearchTerm function
bolu-tife Apr 10, 2022
225bcab
improve transformSearchTerm function
bolu-tife Apr 10, 2022
b0f2b91
Merge branch 'develop' into fix/matrix-link-search
bolu-tife Apr 14, 2022
4c6e4c0
add review changes
bolu-tife Apr 15, 2022
bef2ac5
Signed-off-by: Boluwatife Omosowon <[email protected]>
bolu-tife Apr 16, 2022
a33c486
Merge branch 'develop' into fix/matrix-link-search
bolu-tife Apr 16, 2022
1dba919
add angle brackets to copyright email title
bolu-tife Apr 16, 2022
c26fbf2
removed extra space
bolu-tife Apr 17, 2022
bd46c1e
merged develop into branch
Mar 3, 2023
3adaca0
Update src/utils/SearchInput.ts
bolu-tife Mar 6, 2023
201679f
Merge branch 'fix/matrix-link-search' of https://github.com/bolu-tife…
Mar 6, 2023
2dfea11
fixed spolight dialog search for room and user links
Mar 7, 2023
23b9f10
added tests for transformSearchTerm
Mar 7, 2023
897a099
removed transformSearchTerm from room search bar
Mar 7, 2023
db0a434
Merge branch 'develop' into fix/matrix-link-search
bolu-tife Mar 7, 2023
2380985
Merge branch 'matrix-org:develop' into fix/matrix-link-search
bolu-tife Apr 21, 2023
9877e29
replaces two test cases to one that should return the primaryEntityId…
May 1, 2023
818fe72
Merge branch 'develop' into fix/matrix-link-search
bolu-tife May 1, 2023
67da64d
Merge branch 'develop' into fix/matrix-link-search
bolu-tife May 2, 2023
a8364e6
corrected ts issues
May 3, 2023
49fcb95
Merge branch 'fix/matrix-link-search' of https://github.com/bolu-tife…
May 3, 2023
d63b7e8
Merge branch 'develop' into fix/matrix-link-search
bolu-tife May 3, 2023
f42aea9
changed type of transformSearchTerm to string
May 3, 2023
a973adf
changed return value from empty string to the original search term if…
May 5, 2023
89d7636
changed return value from empty string to the original search term if…
May 5, 2023
377fd93
refactored transformSearchTerm and added a new test case
May 5, 2023
bd055d5
rewrote transformSearchTerm doc
May 5, 2023
682d3f8
changed mocked return values of test case - should return the origina…
May 5, 2023
825e1ce
lint corrections
May 5, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.indexOf("#") +2);
t3chguy marked this conversation as resolved.
Show resolved Hide resolved
};

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()) || "",
});

bolu-tife marked this conversation as resolved.
Show resolved Hide resolved
// 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.indexOf("#") +2);
};

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
6 changes: 5 additions & 1 deletion src/components/views/dialogs/SpotlightDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,10 @@ export const useWebSearchMetrics = (numResults: number, queryLength: number, via
}, [numResults, queryLength, viaSpotlight]);
};

function transformSearchTerm(term: string): string {
return term.substring(term.indexOf("#") +2);
};

bolu-tife marked this conversation as resolved.
Show resolved Hide resolved
const SpotlightDialog: React.FC<IProps> = ({ initialText = "", onFinished }) => {
const cli = MatrixClientPeg.get();
const rovingContext = useContext(RovingTabIndexContext);
Expand Down Expand Up @@ -305,7 +309,7 @@ const SpotlightDialog: React.FC<IProps> = ({ initialText = "", onFinished }) =>
const [spaceResults, spaceResultsLoading] = useSpaceResults(activeSpace, query);

const setQuery = (e: ChangeEvent<HTMLInputElement>): void => {
const newQuery = e.currentTarget.value;
const newQuery = transformSearchTerm(e.currentTarget.value);
_setQuery(newQuery);

setImmediate(() => {
Expand Down