@@ -205,7 +205,7 @@ class Collection extends React.Component {
205205 if (
206206 this . props . user != null &&
207207 this . props . user . username &&
208- this . props . collection . owner . username === this . props . user . username
208+ this . props . collection ? .owner ? .username === this . props . user . username
209209 ) {
210210 isOwner = true ;
211211 }
@@ -214,15 +214,15 @@ class Collection extends React.Component {
214214 }
215215
216216 hasCollection ( ) {
217- return ! this . props . loading && this . props . collection != null ;
217+ return ! ! this . props . collection ;
218218 }
219219
220220 hasCollectionItems ( ) {
221221 return this . hasCollection ( ) && this . props . collection . items . length > 0 ;
222222 }
223223
224224 _renderLoader ( ) {
225- if ( this . props . loading ) return < Loader /> ;
225+ if ( this . props . loading && ! this . hasCollection ( ) ) return < Loader /> ;
226226 return null ;
227227 }
228228
@@ -336,11 +336,7 @@ class Collection extends React.Component {
336336 }
337337
338338 _renderEmptyTable ( ) {
339- const isLoading = this . props . loading ;
340- const hasCollectionItems =
341- this . props . collection != null && this . props . collection . items . length > 0 ;
342-
343- if ( ! isLoading && ! hasCollectionItems ) {
339+ if ( this . hasCollection ( ) && ! this . hasCollectionItems ( ) ) {
344340 return (
345341 < p className = "collection-empty-message" >
346342 { this . props . t ( 'Collection.NoSketches' ) }
@@ -516,13 +512,7 @@ Collection.propTypes = {
516512
517513Collection . defaultProps = {
518514 username : undefined ,
519- collection : {
520- id : undefined ,
521- items : [ ] ,
522- owner : {
523- username : undefined
524- }
525- }
515+ collection : null
526516} ;
527517
528518function mapStateToProps ( state , ownProps ) {
0 commit comments