Skip to content

Commit

Permalink
fix events not visible on end date
Browse files Browse the repository at this point in the history
it wouldn't show events on days where
there would be no other event starting.

SDCP-711
  • Loading branch information
petrjasek committed Sep 26, 2023
1 parent 00c6c0b commit 0b04491
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
5 changes: 3 additions & 2 deletions client/selectors/tests/events_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down
7 changes: 1 addition & 6 deletions client/utils/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -890,11 +890,6 @@ function getEventsByDate(events: Array<IEventItem>, 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 = {};

Expand Down Expand Up @@ -945,7 +940,7 @@ function getEventsByDate(events: Array<IEventItem>, 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);
}
}
Expand Down

0 comments on commit 0b04491

Please sign in to comment.