Skip to content

Commit 3de13cf

Browse files
authored
Merge pull request #1631 from daostack/1585-fix-duplicate-daos-when-searching
Fix duplicate DAOs when searching using capital characters
2 parents 9d9d4fb + 2867ac5 commit 3de13cf

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/components/Daos/DaosPage.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,13 @@ class DaosPage extends React.Component<IProps, IState> {
6767
// If search string greater than 2 search on server for any other DAOs not yet loaded that match this search
6868
if (searchString.length > 2) {
6969
const arc = getArc();
70+
const firstChar = searchString.charAt(0);
7071
const foundDaos = await combineLatest(
7172
// eslint-disable-next-line @typescript-eslint/camelcase
7273
arc.daos({ orderBy: "name", orderDirection: "asc", where: { name_contains: searchString } }, { fetchAllData: true }),
74+
// If string is all lower case also search for string with first character uppercased so "gen" matches "Gen" too
7375
// eslint-disable-next-line @typescript-eslint/camelcase
74-
arc.daos({ orderBy: "name", orderDirection: "asc", where: { name_contains: searchString.charAt(0).toUpperCase() + searchString.slice(1) } }, { fetchAllData: true }),
76+
firstChar.toLowerCase() === firstChar ? arc.daos({ orderBy: "name", orderDirection: "asc", where: { name_contains: firstChar.toUpperCase() + searchString.slice(1) } }, { fetchAllData: true }) : of([]),
7577
(data1, data2) => data1.concat(data2),
7678
).pipe(first()).toPromise();
7779
this.setState({ searchDaos: foundDaos });

0 commit comments

Comments
 (0)