Skip to content

Commit

Permalink
feat: shuffle all apps
Browse files Browse the repository at this point in the history
  • Loading branch information
Karlen9 committed Sep 18, 2024
1 parent d8464c1 commit 560c93f
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 11 deletions.
6 changes: 1 addition & 5 deletions apps/common/components/CategorySection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ type TAppSectionProps = {
title: string;
onExpandClick: () => void;
apps: TApp[];
shouldRandomize?: boolean;
};

export function CategorySection({title, onExpandClick, apps, shouldRandomize = false}: TAppSectionProps): ReactElement {
export function CategorySection({title, onExpandClick, apps}: TAppSectionProps): ReactElement {
const [shuffledApps, set_shuffledApps] = useState<TApp[]>([]);

/**********************************************************************************************
Expand All @@ -23,9 +22,6 @@ export function CategorySection({title, onExpandClick, apps, shouldRandomize = f
if (apps.length < 1) {
return;
}
if (!shouldRandomize) {
return set_shuffledApps(apps);
}
set_shuffledApps(apps.toSorted(() => 0.5 - Math.random()));
});
return (
Expand Down
7 changes: 2 additions & 5 deletions pages/home/[category].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,13 @@ export default function Index(props: {router: NextRouter}): ReactElement {
}, [props.router.asPath]);

/**********************************************************************************************
** On component mount we shuffle the array of Integration Apps to avoid any bias.
** On component mount we shuffle the array of Apps to avoid any bias.
**********************************************************************************************/
useMountEffect(() => {
if (currentCatrgory.apps.length < 1) {
return;
}
if (currentCatrgory.categoryName === 'Integrations') {
set_shuffledApps(currentCatrgory.apps.toSorted(() => 0.5 - Math.random()));
}
set_shuffledApps(currentCatrgory.apps);
set_shuffledApps(currentCatrgory.apps.toSorted(() => 0.5 - Math.random()));
});

return (
Expand Down
1 change: 0 additions & 1 deletion pages/home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ export default function Home(): ReactElement {
/>

<CategorySection
shouldRandomize={true}
title={'Integrations'}
onExpandClick={() => router.push('/home/integrations')}
apps={INTEGRATIONS_APPS}
Expand Down

0 comments on commit 560c93f

Please sign in to comment.