diff --git a/src/modules/browse/screens/Browse.tsx b/src/modules/browse/screens/Browse.tsx index 139d2162..a1d49769 100644 --- a/src/modules/browse/screens/Browse.tsx +++ b/src/modules/browse/screens/Browse.tsx @@ -58,7 +58,7 @@ export function Browse() { - + diff --git a/src/modules/source/components/SourceCard.tsx b/src/modules/source/components/SourceCard.tsx index febf6641..21bddb20 100644 --- a/src/modules/source/components/SourceCard.tsx +++ b/src/modules/source/components/SourceCard.tsx @@ -59,12 +59,7 @@ export const SourceCard: React.FC = (props: IProps) => { ); return ( - + ('shownSourceLangs', getDefaultLanguages()); @@ -66,6 +70,23 @@ export function Sources() { () => SourceService.areFromMultipleRepos(filteredSources), [filteredSources], ); + const visibleSources = useMemo( + () => sourcesByLanguage.map(([, sourcesOfLanguage]) => sourcesOfLanguage).flat(1), + [sourcesByLanguage], + ); + + const groupCounts = useMemo( + () => sourcesByLanguage.map((sourceGroup) => sourceGroup[1].length), + [sourcesByLanguage], + ); + const computeItemKey = VirtuosoUtil.useCreateGroupedComputeItemKey( + groupCounts, + useCallback((index) => sourcesByLanguage[index][0], [sourcesByLanguage]), + useCallback( + (index, groupIndex) => `${sourcesByLanguage[groupIndex][0]}_${visibleSources[index].id}`, + [visibleSources], + ), + ); const navigate = useNavigate(); @@ -102,27 +123,32 @@ export function Sources() { } return ( - <> - {sourcesByLanguage.map(([language, sourcesOfLanguage]) => ( - - - {translateExtensionLanguage(language)} - - {sourcesOfLanguage.map((source) => ( - - ))} - - ))} - + { + const [language] = sourcesByLanguage[index]; + + return ( + + + {translateExtensionLanguage(language)} + + + ); + }} + itemContent={(index) => { + const source = visibleSources[index]; + + return ( + + + + ); + }} + /> ); }