@@ -13,19 +13,16 @@ import ArrowDownIcon from '../../../images/sort-arrow-down.svg';
1313import CollectionMetadata from './CollectionMetadata' ;
1414import CollectionItemRow from './CollectionItemRow' ;
1515
16- const Collection = ( { collectionId } ) => {
16+ const Collection = ( { collectionId, username } ) => {
1717 const { t } = useTranslation ( ) ;
1818 const dispatch = useDispatch ( ) ;
1919
20- const { user, collection, sorting, loading, username } = useSelector (
21- ( state ) => ( {
22- user : state . user ,
23- collection : getCollection ( state , collectionId ) ,
24- sorting : state . sorting ,
25- loading : state . loading ,
26- username : state . user . username
27- } )
28- ) ;
20+ const { user, collection, sorting, loading } = useSelector ( ( state ) => ( {
21+ user : state . user ,
22+ collection : getCollection ( state , collectionId ) ,
23+ sorting : state . sorting ,
24+ loading : state . loading
25+ } ) ) ;
2926
3027 useEffect ( ( ) => {
3128 dispatch ( CollectionsActions . getCollections ( username ) ) ;
@@ -34,7 +31,7 @@ const Collection = ({ collectionId }) => {
3431
3532 const isOwner = ( ) =>
3633 user != null &&
37- user . username &&
34+ typeof user . username !== 'undefined' &&
3835 collection ?. owner ?. username === user . username ;
3936
4037 const hasCollection = ( ) => ! ! collection ;
@@ -160,7 +157,8 @@ const Collection = ({ collectionId }) => {
160157} ;
161158
162159Collection . propTypes = {
163- collectionId : PropTypes . string . isRequired
160+ collectionId : PropTypes . string . isRequired ,
161+ username : PropTypes . string . isRequired
164162} ;
165163
166164export default Collection ;
0 commit comments