removed the localStorage thing again. If this is to be used I need to add a compare-function to make sure that new events are added to the local storage.

This commit is contained in:
Eli 2021-05-10 09:47:34 +02:00
parent fa8de53a12
commit d2abcf24d1
1 changed files with 2 additions and 9 deletions

View File

@ -123,16 +123,9 @@ export default class Calendar extends React.Component<ICalendarProps, ICalendarS
this.userListPermissions = await this.spService.getUserPermissions(this.props.siteUrl, this.props.list); this.userListPermissions = await this.spService.getUserPermissions(this.props.siteUrl, this.props.list);
let allEventsData: IEventData[]; const eventsData: IEventData[] = await this.spService.getEvents(escape(this.props.siteUrl), escape(this.props.list), this.props.eventStartDate.value, this.props.eventEndDate.value);
if(window.localStorage.getItem("calendarEvents")){
allEventsData = JSON.parse(window.localStorage.getItem("calendarEvents"));
}else{
allEventsData = await this.spService.getEvents(escape(this.props.siteUrl), escape(this.props.list), this.props.eventStartDate.value, this.props.eventEndDate.value);
window.localStorage.setItem("calendarEvents", JSON.stringify(allEventsData));
}
// const eventsData: IEventData[] = await this.spService.getEvents(escape(this.props.siteUrl), escape(this.props.list), this.props.eventStartDate.value, this.props.eventEndDate.value);
this.setState({ eventData: allEventsData, hasError: false, errorMessage: "" }); this.setState({ eventData: eventsData, hasError: false, errorMessage: "" });
} catch (error) { } catch (error) {
this.setState({ hasError: true, errorMessage: error.message, isloading: false }); this.setState({ hasError: true, errorMessage: error.message, isloading: false });
} }