[FIX] Select proper event ids to fetch when clicking on event

This commit is contained in:
Franc Camps-Febrer
2018-12-03 19:00:09 +00:00
parent 9bca9788ef
commit 41a92ae719
2 changed files with 12 additions and 4 deletions

View File

@@ -22,6 +22,8 @@ class Dashboard extends React.Component {
this.handleToggle = this.handleToggle.bind(this);
this.handleTagFilter = this.handleTagFilter.bind(this);
this.handleTimeFilter = this.handleTimeFilter.bind(this);
this.eventsById = {};
}
componentDidMount() {
@@ -35,9 +37,15 @@ class Dashboard extends React.Component {
this.props.actions.updateHighlighted((highlighted) ? highlighted : null);
}
getEventById(eventId) {
if (this.eventsById[eventId]) return this.eventsById[eventId];
this.eventsById[eventId] = this.props.domain.events.find(ev => ev.id === eventId);
return this.eventsById[eventId];
}
handleSelect(selected) {
if (selected) {
let eventsToSelect = selected.map(eventId => this.props.domain.events[eventId]);
let eventsToSelect = selected.map(eventId => this.getEventById(eventId));
const parser = this.props.ui.tools.parser;
eventsToSelect = eventsToSelect.sort((a, b) => {
@@ -53,7 +61,7 @@ class Dashboard extends React.Component {
this.props.actions.fetchEvents(selected)
.then((events) => {
let eventsSelected = events.map(ev => {
return Object.assign({}, ev, this.props.domain.events[ev.id]);
return Object.assign({}, ev, this.getEventById(ev.id));
});
eventsSelected = eventsSelected.sort((a, b) => {

View File

@@ -31,14 +31,14 @@ export default class Notification extends React.Component{
const { type, message, items } = notification;
return (
<React.Fragment>
<div>
<div className={`message ${type}`}>
{`${message}`}
</div>
<div className={`details ${this.state.isExtended}`}>
{(items !== null) ? this.renderItems(items) : ''}
</div>
</React.Fragment>
</div>
)
}