Skip to content

Commit

Permalink
fix: gh-46 search input error toast.
Browse files Browse the repository at this point in the history
  • Loading branch information
riccox committed Jun 21, 2023
1 parent f90a200 commit f383bbc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/components/ErrorBoundary/Fallback/AppFallback.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const AppFallback: FC<ErrorFallbackProps> = ({ error }) => {
>
<div className={`text-xl`}>
<p>{error.message}</p>
<a onClick={handleReload}>Reload</a>
<p className='link' onClick={handleReload}>Reload</p>
</div>
</Alert>
</div>
Expand Down
25 changes: 15 additions & 10 deletions src/pages/index/documents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,21 @@ export const Documents = () => {
const { q, limit, offset, filter, sort } = { ...searchForm.values, ...(queryKey[3] as typeof searchForm.values) };
// prevent app error from request param invalid
if (searchForm.validate().hasErrors) return emptySearchResult;
const data = await indexClient!.search(q, {
limit,
offset,
filter,
sort: sort
.split(',')
.filter((v) => v.trim().length > 0)
.map((v) => v.trim()),
});
return data || emptySearchResult;
try {
const data = await indexClient!.search(q, {
limit,
offset,
filter,
sort: sort
.split(',')
.filter((v) => v.trim().length > 0)
.map((v) => v.trim()),
});
return data || emptySearchResult;
} catch (err) {
toast((err as Error).message, { type: 'error' });
return emptySearchResult;
}
},
{
enabled: !!currentIndex,
Expand Down

0 comments on commit f383bbc

Please sign in to comment.