Skip to content

Commit

Permalink
update graphql to case insensitive (#606)
Browse files Browse the repository at this point in the history
  • Loading branch information
yayay927 authored Dec 21, 2021
1 parent a220d60 commit dd2523b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/graphql/desmos_profile_graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ query DesmosProfileLink($address: String) {
// use this query if using dtag
export const DesmosProfileDtagDocument = /* GraphQL */`
query DesmosProfileDtag($dtag: String) {
profile(where: {dtag: {_eq: $dtag}}, limit: 1) {
profile(where: {dtag: {_ilike: $dtag}}, limit: 1) {
address
bio
dtag
Expand Down
10 changes: 9 additions & 1 deletion src/screens/profile_details/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,20 @@ export const useProfileDetails = () => {
if (!regexCheck || !configProfile) {
router.replace('/');
}

if (configProfile) {
fetchDesmosProfile(R.pathOr('', ['query', 'dtag'], router));
}
}, [R.pathOr('', ['query', 'dtag'], router)]);

useEffect(() => {
if (state.desmosProfile) {
const dtagInput = router.query.dtag as string;
if ((`@${state.desmosProfile.dtag}` !== dtagInput) && (`@${state.desmosProfile.dtag.toUpperCase()}` === dtagInput.toUpperCase())) {
router.push({ pathname: `/@${state.desmosProfile.dtag}` }, `/@${state.desmosProfile.dtag}`, { shallow: true });
}
}
}, [state.desmosProfile]);

return {
state,
};
Expand Down
2 changes: 2 additions & 0 deletions src/screens/profile_details/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ jest.mock('next/router', () => ({
query: {
dtag: '@dtag',
},
pathname: '/@dtag',
replace: jest.fn(() => '/'),
push: jest.fn(() => ('/@dtag')),
}),
}));

Expand Down

0 comments on commit dd2523b

Please sign in to comment.