Skip to content

Commit

Permalink
Fix count unread news in unread activities
Browse files Browse the repository at this point in the history
  • Loading branch information
louilinn committed Oct 27, 2023
1 parent 2aa7222 commit 0c2d58b
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions src/components/ActivityIcon.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,25 @@ const DashboardActivityIcon = () => {
});
});

// Count how many activities we haven't seen yet
const count = CATEGORIES.reduce((acc, category) => {
return (
acc +
categories[category].activities.reduce((itemAcc, activity) => {
return activity.createdAt > lastSeenAt ? itemAcc + 1 : itemAcc;
}, 0)
);
}, 0);

const countNews = news.activities.reduce((itemAcc, activity) => {
return activity.createdAt > lastSeenAt ? itemAcc + 1 : itemAcc;
}, 0);

// Count how many activities we haven't seen yet
const count =
CATEGORIES.reduce((acc, category) => {
/* eslint-disable no-console */
console.log(category);
/* eslint-enable no-console */

return (
acc +
categories[category].activities.reduce((itemAcc, activity) => {
return activity.createdAt > lastSeenAt ? itemAcc + 1 : itemAcc;
}, 0)
);
}, 0) + countNews;

return (
<IconButton
aria-label="Activities"
Expand Down

0 comments on commit 0c2d58b

Please sign in to comment.