Author: jruchaud Date: 2015-05-04 12:17:13 +0000 (Mon, 04 May 2015) New Revision: 1320 Url: http://forge.nuiton.org/projects/sandbox/repository/revisions/1320 Log: Fix timeline refresh Modified: wit/js/components/FilterLogs.js wit/js/components/Timeline.js Modified: wit/js/components/FilterLogs.js =================================================================== --- wit/js/components/FilterLogs.js 2015-05-04 10:57:53 UTC (rev 1319) +++ wit/js/components/FilterLogs.js 2015-05-04 12:17:13 UTC (rev 1320) @@ -191,7 +191,7 @@ ); r.push( <tr ref={key} className="hidden"> - <td colSpan="4"><Timeline data={tagObject}/></td> + <td colSpan="4"><Timeline data={tagObject} key={key}/></td> </tr> ); } Modified: wit/js/components/Timeline.js =================================================================== --- wit/js/components/Timeline.js 2015-05-04 10:57:53 UTC (rev 1319) +++ wit/js/components/Timeline.js 2015-05-04 12:17:13 UTC (rev 1320) @@ -4,32 +4,16 @@ var Timeline = React.createClass({ getInitialState: function() { - var data = this.props.data; - - this.startDate = data && data.startDate && moment(data.startDate), - this.endDate = data && data.endDate && moment(data.endDate); - return { - sessions: [], + sessions: [] }; }, componentDidMount: function () { - - // Retrieve window focus activity + var startDate = this.props.data.startDate && moment(this.props.data.startDate); + var endDate = this.props.data.endDate && moment(this.props.data.endDate); - this.refresh(this.startDate, this.endDate); - }, - - componentWillReceiveProps: function(nextProps) { - this.refresh(nextProps.data.startDate, nextProps.data.endDate); - }, - - refresh: function (startDate, endDate) { if (startDate && endDate) { - this.startDate = startDate; - this.endDate = endDate; - var self = this; user.getSessions(startDate, endDate, true) @@ -48,14 +32,17 @@ // Create a wrapper for each window session + var startDate = this.props.data.startDate && moment(this.props.data.startDate); + var endDate = this.props.data.endDate && moment(this.props.data.endDate); + var self = this, - timeRange = this.endDate && this.endDate.diff(this.startDate); + timeRange = endDate && endDate.diff(startDate); items = items.concat( sessions.map(function(session) { var rst = ""; - var ns = self._normalize(session, self.startDate, self.endDate); // normalize session according to timeline boundaries + var ns = self._normalize(session, startDate, endDate); // normalize session according to timeline boundaries var data = { title: ns.name,