Skip to content

Commit

Permalink
fix(entity): entity.maxDaysToShow not working
Browse files Browse the repository at this point in the history
fixes #1191
  • Loading branch information
marksie1988 committed Oct 3, 2023
1 parent b2c6898 commit bddb8b4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ export class AtomicCalendarRevive extends LitElement {
/**
* If there are no events, put some text in
*/
if (days.length === 0 && this._config.maxDaysToShow == 1) {
if (days.length === 0 && (this._config.maxDaysToShow == 1 || this._config.maxDaysToShow == 0)) {
this.content = this._config.noEventText;
return;
} else if (days.length === 0) {
Expand Down
6 changes: 5 additions & 1 deletion src/lib/event.func.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ export async function getAllEvents(start: dayjs.Dayjs, end: dayjs.Dayjs, config:
const dateFormat = 'YYYY-MM-DDTHH:mm:ss';

const startTime = start.startOf('day').format(dateFormat);
const endTime = end.endOf('day').format(dateFormat);

// for each calendar entity get all events
// each entity may be a string of entity id or
Expand All @@ -160,6 +159,11 @@ export async function getAllEvents(start: dayjs.Dayjs, end: dayjs.Dayjs, config:
config.entities.map((entity) => {
const calendarEntity = (entity && entity.entity) || entity;

const endTime = entity.maxDaysToShow! !== undefined ? dayjs()
.add(entity.maxDaysToShow! - 1 + config.startDaysAhead!, 'day')
.endOf('day')
.format('YYYY-MM-DDTHH:mm:ss') : end.endOf('day').format(dateFormat);;

const url: string = `calendars/${entity.entity}?start=${startTime}Z&end=${endTime}Z`;

// make all requests at the same time
Expand Down

0 comments on commit bddb8b4

Please sign in to comment.