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 = ({ ...@@ -26,7 +26,7 @@ const TimelineCard = ({
}: TimelineCardProps): JSX.Element => { }: TimelineCardProps): JSX.Element => {
const timelineUrl = Urls.timelineInCollection(timeline, collection); const timelineUrl = Urls.timelineInCollection(timeline, collection);
const menuItems = getMenuItems(timeline, collection, onUnarchive); const menuItems = getMenuItems(timeline, collection, onUnarchive);
const eventCount = timeline.events?.length; const eventCount = getEventCount(timeline);
const hasDescription = Boolean(timeline.description); const hasDescription = Boolean(timeline.description);
const hasMenuItems = menuItems.length > 0; const hasMenuItems = menuItems.length > 0;
const hasEventCount = !hasMenuItems && eventCount != null; const hasEventCount = !hasMenuItems && eventCount != null;
...@@ -58,6 +58,10 @@ const TimelineCard = ({ ...@@ -58,6 +58,10 @@ const TimelineCard = ({
); );
}; };
const getEventCount = (timeline: Timeline) => {
return timeline.events ? timeline.events.filter(e => !e.archived).length : 0;
};
const getMenuItems = ( const getMenuItems = (
timeline: Timeline, timeline: Timeline,
collection: Collection, collection: Collection,
......
...@@ -11,7 +11,11 @@ describe("TimelineCard", () => { ...@@ -11,7 +11,11 @@ describe("TimelineCard", () => {
it("should render timeline", () => { it("should render timeline", () => {
const props = getProps({ const props = getProps({
timeline: createMockTimeline({ 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