From cb47eb69d14fc2b24b771bb575ef22c4d27a1876 Mon Sep 17 00:00:00 2001 From: malmen237 Date: Mon, 8 Jul 2024 12:06:32 +0200 Subject: [PATCH 1/2] fix: added sorting to production-list to garantee that list returns last 10 items --- .../landing-page/use-fetch-production-list.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/components/landing-page/use-fetch-production-list.ts b/src/components/landing-page/use-fetch-production-list.ts index 142fdd11..0a0a69f4 100644 --- a/src/components/landing-page/use-fetch-production-list.ts +++ b/src/components/landing-page/use-fetch-production-list.ts @@ -21,8 +21,14 @@ export const useFetchProductionList = () => { setProductions( result - // pick laste 10 items - .slice(-10) + + // Make sure list is correctly sorted + .sort( + (a, b) => + parseInt(b.productionId, 10) - parseInt(a.productionId, 10) + ) + // pick last 10 items and display newest first + .slice(0, 10) ); dispatch({ From bce3356f7374e9ba86e88dea819a356f5721383c Mon Sep 17 00:00:00 2001 From: malmen237 Date: Mon, 8 Jul 2024 13:04:02 +0200 Subject: [PATCH 2/2] fix: removed the sorting-addition --- src/components/landing-page/use-fetch-production-list.ts | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/components/landing-page/use-fetch-production-list.ts b/src/components/landing-page/use-fetch-production-list.ts index 0a0a69f4..44eb2740 100644 --- a/src/components/landing-page/use-fetch-production-list.ts +++ b/src/components/landing-page/use-fetch-production-list.ts @@ -21,12 +21,6 @@ export const useFetchProductionList = () => { setProductions( result - - // Make sure list is correctly sorted - .sort( - (a, b) => - parseInt(b.productionId, 10) - parseInt(a.productionId, 10) - ) // pick last 10 items and display newest first .slice(0, 10) );