Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion release-calendar/src/client/components/Calendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ export class Calendar extends React.Component<CalendarProps, CalendarState> {
this.apiService = new ApiService();
}

calendarReference = React.createRef<FullCalendar>();

async componentDidMount(): Promise<void> {
const releases = await this.apiService.getReleases();
this.setState({allEvents: getAllReleasesEvents(releases)});
Expand All @@ -68,12 +70,18 @@ export class Calendar extends React.Component<CalendarProps, CalendarState> {
this.props.singleRelease,
);
this.setState({singleEvents: getSingleReleaseEvents(release)});
this.gotoDate(release[0].start);
} else {
this.setState({singleEvents: []});
}
}
}

gotoDate = (date: Date): void => {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason why you use an anonymous function here and not a regular function syntax? (gotoDate(date: Date): void {)

Anonymous functions are more useful when you use them as, say, an argument to another function (e.g., arr.sort((firstEl, secondEl) => { ... }))

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No there wasn't any reason. I just wasn't aware one was the "regular", and I've gotten used to the anonymous way since I use functions as arguments more often. I'll switch this one to the regular function syntax!

const calendarApi = this.calendarReference.current.getApi();
calendarApi.gotoDate(date);
};

tooltip = (arg: {
isMirror: boolean;
isStart: boolean;
Expand Down Expand Up @@ -110,10 +118,11 @@ export class Calendar extends React.Component<CalendarProps, CalendarState> {
<FullCalendar
defaultView='dayGridMonth'
header={{
left: 'prev,next',
left: 'prev,next today',
center: 'title',
right: 'dayGridMonth,timeGridWeek,listWeek',
}}
ref={this.calendarReference}
plugins={[dayGridPlugin, timeGridPlugin]}
eventSources={displayEvents}
contentHeight={CALENDAR_CONTENT_HEIGHT}
Expand Down
1 change: 1 addition & 0 deletions release-calendar/src/client/components/ChannelTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export class ChannelTable extends React.Component<
};
this.apiService = new ApiService();
this.handleChannelClick = this.handleChannelClick.bind(this);
this.handleReleaseClick = this.handleReleaseClick.bind(this);
}

async componentDidMount(): Promise<void> {
Expand Down