Skip to content

Commit

Permalink
feat: refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
zamitto committed Sep 12, 2024
1 parent b0164b6 commit ad3c2df
Showing 1 changed file with 27 additions and 15 deletions.
42 changes: 27 additions & 15 deletions src/renderer/src/pages/home/search-results.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,32 @@ export function SearchResults() {
debouncedFunc.current();
}, [searchParams, dispatch]);

const noResultsContent = () => {
if (isLoading) return null;

if (showTypingMessage) {
return (
<div className={styles.noResults}>
<SearchIcon size={56} />

<p>{t("start_typing")}</p>
</div>
);
}

if (searchResults.length === 0) {
return (
<div className={styles.noResults}>
<InboxIcon size={56} />

<p>{t("no_results")}</p>
</div>
);
}

return null;
};

return (
<SkeletonTheme baseColor={vars.color.background} highlightColor="#444">
<section className={styles.content}>
Expand All @@ -94,21 +120,7 @@ export function SearchResults() {
)}
</section>

{!isLoading && showTypingMessage && (
<div className={styles.noResults}>
<SearchIcon size={56} />

<p>{t("start_typing")}</p>
</div>
)}

{!isLoading && searchResults.length === 0 && (
<div className={styles.noResults}>
<InboxIcon size={56} />

<p>{t("no_results")}</p>
</div>
)}
{noResultsContent()}
</section>
</SkeletonTheme>
);
Expand Down

0 comments on commit ad3c2df

Please sign in to comment.