diff --git a/src/agenda/reservation-list/index.tsx b/src/agenda/reservation-list/index.tsx index f364d9c835..e38be000f5 100644 --- a/src/agenda/reservation-list/index.tsx +++ b/src/agenda/reservation-list/index.tsx @@ -61,7 +61,7 @@ class ReservationList extends Component { selectedDay: PropTypes.instanceOf(XDate), topDay: PropTypes.instanceOf(XDate), onDayChange: PropTypes.func, - + showOnlySelectedDayItems: PropTypes.bool, renderEmptyData: PropTypes.func, @@ -75,7 +75,7 @@ class ReservationList extends Component { onRefresh: PropTypes.func, reservationsKeyExtractor: PropTypes.func }; - + static defaultProps = { refreshing: false, selectedDay: new XDate(true) @@ -108,13 +108,9 @@ class ReservationList extends Component { componentDidUpdate(prevProps: ReservationListProps) { if (this.props.topDay && prevProps.topDay && prevProps !== this.props) { - if (!sameDate(prevProps.topDay, this.props.topDay)) { - this.setState({reservations: []}, - () => this.updateReservations(this.props) - ); - } else { - this.updateReservations(this.props); - } + this.setState({reservations: []}, + () => this.updateReservations(this.props) + ); } } @@ -125,7 +121,7 @@ class ReservationList extends Component { updateReservations(props: ReservationListProps) { const {selectedDay, showOnlySelectedDayItems} = props; const reservations = this.getReservations(props); - + if (!showOnlySelectedDayItems && this.list && !sameDate(selectedDay, this.selectedDay)) { let scrollPosition = 0; for (let i = 0; i < reservations.scrollPosition; i++) { @@ -142,7 +138,7 @@ class ReservationList extends Component { getReservationsForDay(iterator: XDate, props: ReservationListProps) { const day = iterator.clone(); const res = props.items?.[toMarkingFormat(day)]; - + if (res && res.length) { return res.map((reservation: AgendaEntry, i: number) => { return { @@ -163,7 +159,7 @@ class ReservationList extends Component { getReservations(props: ReservationListProps) { const {selectedDay, showOnlySelectedDayItems} = props; - + if (!props.items || !selectedDay) { return {reservations: [], scrollPosition: 0}; } @@ -262,7 +258,7 @@ class ReservationList extends Component { render() { const {items, selectedDay, theme, style} = this.props; - + if (!items || selectedDay && !items[toMarkingFormat(selectedDay)]) { if (isFunction(this.props.renderEmptyData)) { return this.props.renderEmptyData?.();