Skip to content

Commit

Permalink
fix: correctly order article list
Browse files Browse the repository at this point in the history
  • Loading branch information
Xstoudi committed Jul 17, 2023
1 parent 35d2fd3 commit 3742422
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/components/layout/ArticleList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ function ArticleList() {
const activeFeed = useActiveFeed();
const activeArticle = useActiveArticle();

const articles = useMemo(() => {
if (activeFeed === null) return [];

return activeFeed.articles;
}, [activeFeed]);
const articles = useMemo(
() =>
[...(activeFeed?.articles ?? [])].sort(
({ date: dateA }, { date: dateB }) => dateB.getTime() - dateA.getTime(),
),
[activeFeed],
);

return (
<div className="flex-[5_5_0%] flex flex-col max-w-full min-h-full overflow-y-scroll shadow-custom lg:w-[35rem]">
Expand Down

0 comments on commit 3742422

Please sign in to comment.