From 9c763dac6cdc195210a5a44a0c019b734d3cdcfe Mon Sep 17 00:00:00 2001 From: Ben Gotow Date: Mon, 14 Oct 2019 13:38:20 -0500 Subject: [PATCH] Fix race condition in ListTabular causing thread list to appear blank for some users --- app/src/components/list-tabular.tsx | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/app/src/components/list-tabular.tsx b/app/src/components/list-tabular.tsx index 8b4817717..ccce981d3 100644 --- a/app/src/components/list-tabular.tsx +++ b/app/src/components/list-tabular.tsx @@ -191,12 +191,6 @@ export class ListTabular extends Component { this.setupDataSource(this.props.dataSource); } - componentWillReceiveProps(nextProps) { - if (nextProps.dataSource !== this.props.dataSource) { - this.setupDataSource(nextProps.dataSource); - } - } - componentDidUpdate(prevProps, prevState) { if (this.props.onComponentDidUpdate) { this.props.onComponentDidUpdate(); @@ -205,15 +199,16 @@ export class ListTabular extends Component { // reset our scroll position to the top. if (prevProps.dataSource !== this.props.dataSource) { this._scrollRegion.scrollTop = 0; + this.setupDataSource(this.props.dataSource); } + if (this.updateRangeStateFiring) { this.updateRangeStateFiring = false; } else if ( prevState.count !== this.state.count || - prevProps.itemHeight !== this.props.itemHeight || - prevProps.dataSource !== this.props.dataSource + prevProps.itemHeight !== this.props.itemHeight ) { - this.updateRangeStateIfChanged(); + this.updateRangeStateIfViewportChanged(); } if (!this._cleanupAnimationTimeout) { @@ -231,7 +226,7 @@ export class ListTabular extends Component { onWindowResize = () => { if (this._onWindowResize == null) { - this._onWindowResize = _.debounce(this.updateRangeStateIfChanged, 50); + this._onWindowResize = _.debounce(this.updateRangeStateIfViewportChanged, 50); } this._onWindowResize(); }; @@ -239,7 +234,7 @@ export class ListTabular extends Component { onScroll = () => { // If we've shifted enough pixels from our previous scrollTop to require // new rows to be rendered, update our state! - this.updateRangeStateIfChanged(); + this.updateRangeStateIfViewportChanged(); }; onCleanupAnimatingItems = () => { @@ -326,7 +321,7 @@ export class ListTabular extends Component { return { start: rangeStart, end: rangeEnd }; } - updateRangeStateIfChanged() { + updateRangeStateIfViewportChanged() { const range = this.getRange(); // Final sanity check to prevent needless work