diff options
author | Joram Wilander <jwawilander@gmail.com> | 2016-04-26 12:28:27 -0400 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2016-04-26 12:28:27 -0400 |
commit | 215f78af147350088516a918afb8b84db492787a (patch) | |
tree | e94f1258aa197e47015c18823d48a47c1011f954 /webapp/components/analytics/line_chart.jsx | |
parent | c41cd44ada5f6c343e07d2ebde2a6a04a6b7a49c (diff) | |
download | chat-215f78af147350088516a918afb8b84db492787a.tar.gz chat-215f78af147350088516a918afb8b84db492787a.tar.bz2 chat-215f78af147350088516a918afb8b84db492787a.zip |
Prevent graphs bouncing multiples times when loading analytics pages (#2800)
Diffstat (limited to 'webapp/components/analytics/line_chart.jsx')
-rw-r--r-- | webapp/components/analytics/line_chart.jsx | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/webapp/components/analytics/line_chart.jsx b/webapp/components/analytics/line_chart.jsx index 6a3b8c0f0..f45e7f5fa 100644 --- a/webapp/components/analytics/line_chart.jsx +++ b/webapp/components/analytics/line_chart.jsx @@ -1,11 +1,13 @@ // Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. // See License.txt for license information. -import ReactDOM from 'react-dom'; import {FormattedMessage} from 'react-intl'; -import Chart from 'chart.js'; + +import * as Utils from 'utils/utils.jsx'; import React from 'react'; +import ReactDOM from 'react-dom'; +import Chart from 'chart.js'; export default class LineChart extends React.Component { constructor(props) { @@ -19,11 +21,13 @@ export default class LineChart extends React.Component { this.initChart(); } - componentDidUpdate() { - if (this.chart) { - this.chart.destroy(); + componentDidUpdate(prevProps) { + if (!Utils.areObjectsEqual(prevProps.data, this.props.data) || !Utils.areObjectsEqual(prevProps.options, this.props.options)) { + if (this.chart) { + this.chart.destroy(); + } + this.initChart(); } - this.initChart(); } componentWillUnmount() { |