Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: switch pages and endpoints #1634

Merged
merged 2 commits into from
Oct 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 23 additions & 23 deletions packages/ui/app/src/search/SearchHits.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ export const SearchHits: React.FC = () => {
setExpandPages(false);
}, [hits]);
useEffect(() => {
const { endpointHits, pageHits } = filterHits(hits);
setOrderedHits([...expandHits(expandEndpoints, endpointHits), ...expandHits(expandPages, pageHits)]);
const { pageHits, endpointHits } = filterHits(hits);
setOrderedHits([...expandHits(expandPages, pageHits), ...expandHits(expandEndpoints, endpointHits)]);
}, [hits, expandEndpoints, expandPages]);

const hoveredSearchHit = useMemo(() => {
Expand Down Expand Up @@ -259,23 +259,23 @@ export const SearchHits: React.FC = () => {
onMouseEnter={() => setHoveredSearchHitId(COHERE_AI_HIT_ID)}
/>
)}
{endpointHits.length > 0 && (
{pageHits.length > 0 && (
<SearchSection
title="Endpoints"
hits={endpointHits}
expanded={expandEndpoints}
setExpanded={setExpandEndpoints}
title="Pages"
hits={pageHits}
expanded={expandPages}
setExpanded={setExpandPages}
refs={refs}
hoveredSearchHitId={hoveredSearchHitId}
setHoveredSearchHitId={setHoveredSearchHitId}
/>
)}
{pageHits.length > 0 && (
{endpointHits.length > 0 && (
<SearchSection
title="Pages"
hits={pageHits}
expanded={expandPages}
setExpanded={setExpandPages}
title="Endpoints"
hits={endpointHits}
expanded={expandEndpoints}
setExpanded={setExpandEndpoints}
refs={refs}
hoveredSearchHitId={hoveredSearchHitId}
setHoveredSearchHitId={setHoveredSearchHitId}
Expand Down Expand Up @@ -318,6 +318,15 @@ export const SearchMobileHits: React.FC<PropsWithChildren> = ({ children }) => {
isHovered={true}
/>
)}
{pageHits.length > 0 && (
<MobileSearchSection
title="Pages"
hits={pageHits}
expanded={expandPages}
setExpanded={setExpandPages}
refs={refs}
/>
)}
{endpointHits.length > 0 && (
<MobileSearchSection
title="Endpoints"
Expand All @@ -327,15 +336,6 @@ export const SearchMobileHits: React.FC<PropsWithChildren> = ({ children }) => {
refs={refs}
/>
)}
{pageHits.length > 0 && (
<MobileSearchSection
title="Fields"
hits={pageHits}
expanded={expandPages}
setExpanded={setExpandPages}
refs={refs}
/>
)}
</FernScrollArea>
);
};
Expand All @@ -358,8 +358,8 @@ function filterHits(hits: SearchRecord[]) {
pages: new Set(["page", "page-v2", "page-v3", "page-v4", "markdown-section-v1"]),
};

const endpointHits = hits.filter((hit) => hitTypeMap["endpoints"].has(hit.type));
const pageHits = hits.filter((hit) => hitTypeMap["pages"].has(hit.type));
const endpointHits = hits.filter((hit) => hitTypeMap["endpoints"].has(hit.type));

return { endpointHits, pageHits };
return { pageHits, endpointHits };
}
Loading