From 71f7df252ae5ca69bfc7425d57d2b673c277bbbe Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Thu, 22 Feb 2018 20:58:55 +0000 Subject: [PATCH] Fix event editing. It was crashing due to 7917b1fbe1e03da2829cf91df1b7df8ab05804f3. --- src/components/EventEdit.tsx | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/components/EventEdit.tsx b/src/components/EventEdit.tsx index 5861ca0..541ce31 100644 --- a/src/components/EventEdit.tsx +++ b/src/components/EventEdit.tsx @@ -63,14 +63,16 @@ class EventEdit extends React.PureComponent { }; const locState = this.props.location.state; - // FIXME: Hack to determine if all day. Should be passed as a proper state. - this.state.allDay = (locState.start && - (locState.start.getHours() === 0) && - (locState.start.getMinutes() === 0) && - (locState.start.getHours() === locState.end.getHours()) && - (locState.start.getMinutes() === locState.end.getMinutes())); - this.state.start = (locState.start) ? locState.start : undefined; - this.state.end = (locState.end) ? locState.end : undefined; + if (locState) { + // FIXME: Hack to determine if all day. Should be passed as a proper state. + this.state.allDay = (locState.start && + (locState.start.getHours() === 0) && + (locState.start.getMinutes() === 0) && + (locState.start.getHours() === locState.end.getHours()) && + (locState.start.getMinutes() === locState.end.getMinutes())); + this.state.start = (locState.start) ? locState.start : undefined; + this.state.end = (locState.end) ? locState.end : undefined; + } if (this.props.item !== undefined) { const event = this.props.item;