Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 5 additions & 15 deletions client/modules/User/components/Collection.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ class Collection extends React.Component {
if (
this.props.user != null &&
this.props.user.username &&
this.props.collection.owner.username === this.props.user.username
this.props.collection?.owner?.username === this.props.user.username
) {
isOwner = true;
}
Expand All @@ -214,15 +214,15 @@ class Collection extends React.Component {
}

hasCollection() {
return !this.props.loading && this.props.collection != null;
return !!this.props.collection;
}

hasCollectionItems() {
return this.hasCollection() && this.props.collection.items.length > 0;
}

_renderLoader() {
if (this.props.loading) return <Loader />;
if (this.props.loading && !this.hasCollection()) return <Loader />;
return null;
}

Expand Down Expand Up @@ -336,11 +336,7 @@ class Collection extends React.Component {
}

_renderEmptyTable() {
const isLoading = this.props.loading;
const hasCollectionItems =
this.props.collection != null && this.props.collection.items.length > 0;

if (!isLoading && !hasCollectionItems) {
if (this.hasCollection() && !this.hasCollectionItems()) {
return (
<p className="collection-empty-message">
{this.props.t('Collection.NoSketches')}
Expand Down Expand Up @@ -516,13 +512,7 @@ Collection.propTypes = {

Collection.defaultProps = {
username: undefined,
collection: {
id: undefined,
items: [],
owner: {
username: undefined
}
}
collection: null
};

function mapStateToProps(state, ownProps) {
Expand Down