From 12f385dffd488bfc72e10f89f8c5e2bf9ff3410a Mon Sep 17 00:00:00 2001 From: Kamran Ahmed Date: Fri, 26 May 2023 15:38:04 +0100 Subject: [PATCH] Show the recently updated item on top --- src/components/Activity/ActivityPage.tsx | 86 ++++++++++++++---------- 1 file changed, 50 insertions(+), 36 deletions(-) diff --git a/src/components/Activity/ActivityPage.tsx b/src/components/Activity/ActivityPage.tsx index 1930bf3a8..3268c777a 100644 --- a/src/components/Activity/ActivityPage.tsx +++ b/src/components/Activity/ActivityPage.tsx @@ -101,43 +101,57 @@ export function ActivityPage() { Continue Following
- {learningRoadmaps.reverse().map((roadmap) => ( - { - pageLoadingMessage.set('Updating activity'); - loadActivity().finally(() => { - pageLoadingMessage.set(''); - }); - }} - /> - ))} + {learningRoadmaps + .sort((a, b) => { + const updatedAtA = new Date(a.updatedAt); + const updatedAtB = new Date(b.updatedAt); - {learningBestPractices.reverse().map((bestPractice) => ( - { - pageLoadingMessage.set('Updating activity'); - loadActivity().finally(() => { - pageLoadingMessage.set(''); - }); - }} - /> - ))} + return updatedAtB.getTime() - updatedAtA.getTime(); + }) + .map((roadmap) => ( + { + pageLoadingMessage.set('Updating activity'); + loadActivity().finally(() => { + pageLoadingMessage.set(''); + }); + }} + /> + ))} + + {learningBestPractices + .sort((a, b) => { + const updatedAtA = new Date(a.updatedAt); + const updatedAtB = new Date(b.updatedAt); + + return updatedAtB.getTime() - updatedAtA.getTime(); + }) + .map((bestPractice) => ( + { + pageLoadingMessage.set('Updating activity'); + loadActivity().finally(() => { + pageLoadingMessage.set(''); + }); + }} + /> + ))}
)}