From 83c6612d85f6b4c1fdef6945ba7775b4562d05bf Mon Sep 17 00:00:00 2001 From: Petr Jasek Date: Tue, 26 Sep 2023 10:01:04 +0200 Subject: [PATCH] fix events not visible on end date it wouldn't show events on days where there would be no other event starting. SDCP-711 --- client/selectors/tests/events_test.ts | 5 +++-- client/utils/events.ts | 7 +------ 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/client/selectors/tests/events_test.ts b/client/selectors/tests/events_test.ts index 70cb37b26..cfdd99af2 100644 --- a/client/selectors/tests/events_test.ts +++ b/client/selectors/tests/events_test.ts @@ -67,9 +67,10 @@ describe('selectors', () => { '2017-01-14', '2017-01-15', '2017-01-16', + '2017-01-17', ]); - expect(Object.keys(events).includes('2017-01-17')).toBe(false); + expect(Object.keys(events).includes('2017-01-17')).toBe(true); expect(events['2017-01-14'].events.length).toBe(1); expect(events['2017-01-14'].events[0]._id).toBe('event3'); @@ -176,7 +177,7 @@ describe('selectors', () => { setAdvancedSearchDates(state, '2017-01-16T13:59:59+0000', '2017-01-17T08:00:00+0000'); const events = keyBy(selectors.events.orderedEvents(state), 'date'); - expect(Object.keys(events)).toEqual(['2017-01-16']); + expect(Object.keys(events)).toEqual(['2017-01-16', '2017-01-17']); expect(events['2017-01-16'].events.length).toBe(2); expect(events['2017-01-16'].events[0]._id).toBe('event3'); diff --git a/client/utils/events.ts b/client/utils/events.ts index 12f09d726..2d42eb4e9 100644 --- a/client/utils/events.ts +++ b/client/utils/events.ts @@ -890,11 +890,6 @@ function getEventsByDate(events: Array, startDate: moment.Moment, en // check if search exists // order by date let sortedEvents = events.sort((a, b) => a.dates.start - b.dates.start); - let maxStartDate = sortedEvents[sortedEvents.length - 1].dates.start; - - if (startDate.isAfter(maxStartDate, 'day')) { - maxStartDate = startDate; - } const days = {}; @@ -945,7 +940,7 @@ function getEventsByDate(events: Array, startDate: moment.Moment, en newDate.add(i, 'days'); - if (maxStartDate.isSameOrAfter(newDate, 'day') && newDate.isSameOrBefore(ending, 'day')) { + if (newDate.isSameOrBefore(ending, 'day')) { addEventToDate(event, newDate); } }