Skip to content
Snippets Groups Projects
Unverified Commit ba8b0f59 authored by Alexander Polyankin's avatar Alexander Polyankin Committed by GitHub
Browse files

Count only non-archived events (#21496)

parent bbcaaae2
No related branches found
No related tags found
No related merge requests found
......@@ -26,7 +26,7 @@ const TimelineCard = ({
}: TimelineCardProps): JSX.Element => {
const timelineUrl = Urls.timelineInCollection(timeline, collection);
const menuItems = getMenuItems(timeline, collection, onUnarchive);
const eventCount = timeline.events?.length;
const eventCount = getEventCount(timeline);
const hasDescription = Boolean(timeline.description);
const hasMenuItems = menuItems.length > 0;
const hasEventCount = !hasMenuItems && eventCount != null;
......@@ -58,6 +58,10 @@ const TimelineCard = ({
);
};
const getEventCount = (timeline: Timeline) => {
return timeline.events ? timeline.events.filter(e => !e.archived).length : 0;
};
const getMenuItems = (
timeline: Timeline,
collection: Collection,
......
......@@ -11,7 +11,11 @@ describe("TimelineCard", () => {
it("should render timeline", () => {
const props = getProps({
timeline: createMockTimeline({
events: [createMockTimelineEvent(), createMockTimelineEvent()],
events: [
createMockTimelineEvent(),
createMockTimelineEvent(),
createMockTimelineEvent({ archived: true }),
],
}),
});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment