Skip to content

Commit

Permalink
Merge pull request #606 from subquery/fix/home-search
Browse files Browse the repository at this point in the history
fix: home search
  • Loading branch information
HuberTRoy authored Nov 28, 2023
2 parents 91ab7e1 + 50e0134 commit 4eb0cd4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/hooks/useLocalProjects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,12 @@ export const useLocalProjects = () => {
const res = await getProjects({
variables: {
offset: length,
orderBy: [ProjectsOrderBy.ID_DESC],
orderBy: [ProjectsOrderBy.ID_ASC],
ids: [],
},
defaultOptions: {
fetchPolicy: 'network-only',
},
});

if (res.data?.projects?.nodes) {
Expand All @@ -68,7 +71,6 @@ export const useLocalProjects = () => {
const mergered = uniqWith([...projects.current, ...projectsWithMetadata], (x, y) => x.id === y.id);
projects.current = mergered;
await localforage.setItem(cacheKey, mergered);

if (mergered.length >= res.data.projects.totalCount) {
loading.current = false;
return;
Expand Down
5 changes: 3 additions & 2 deletions src/pages/explorer/Home/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ const Home: React.FC = () => {
} else {
setInSearchMode(false);
}
console.warn(options);

const api = searchKeywords.length ? getProjectBySearch : getProjects;

const params = searchKeywords.length
Expand Down Expand Up @@ -166,6 +166,7 @@ const Home: React.FC = () => {
mutate(res);
}
}}
disabled={loading}
onChange={(e) => {
setSearchKeywords(e.target.value);
}}
Expand Down Expand Up @@ -198,7 +199,7 @@ const Home: React.FC = () => {
})}
</div>

{inSearchMode && !projects.length && (
{inSearchMode && !loading && !projects.length && (
<div style={{ display: 'flex', justifyContent: 'center' }}>
<Typography>No projects match your search</Typography>
</div>
Expand Down

0 comments on commit 4eb0cd4

Please sign in to comment.