From 679304d0abf4601237cf64ae64ea4c6ebe4dd361 Mon Sep 17 00:00:00 2001 From: Andrew Nicolaou Date: Wed, 11 Sep 2019 21:13:34 +0200 Subject: [PATCH] Do not empty table when fetching new data --- .../CollectionList/CollectionList.jsx | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/client/modules/IDE/components/CollectionList/CollectionList.jsx b/client/modules/IDE/components/CollectionList/CollectionList.jsx index cbf0613f..58b9bc45 100644 --- a/client/modules/IDE/components/CollectionList/CollectionList.jsx +++ b/client/modules/IDE/components/CollectionList/CollectionList.jsx @@ -28,6 +28,18 @@ class CollectionList extends React.Component { this.props.getCollections(this.props.username); this.props.resetSorting(); this._renderFieldHeader = this._renderFieldHeader.bind(this); + + this.state = { + hasLoadedData: false, + }; + } + + componentDidUpdate(prevProps) { + if (prevProps.loading === true && this.props.loading === false) { + this.setState({ + hasLoadedData: true, + }); + } } getTitle() { @@ -38,11 +50,11 @@ class CollectionList extends React.Component { } hasCollections() { - return !this.props.loading && this.props.collections.length > 0; + return (!this.props.loading || this.state.hasLoadedData) && this.props.collections.length > 0; } _renderLoader() { - if (this.props.loading) return ; + if (this.props.loading && !this.state.hasLoadedData) return ; return null; } @@ -78,7 +90,7 @@ class CollectionList extends React.Component { const username = this.props.username !== undefined ? this.props.username : this.props.user.username; return ( -
+
{this.getTitle()}