@@ -13,19 +13,14 @@ 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 = useSelector ( ( state ) => state . user ) ;
21+ const collection = useSelector ( ( state ) => getCollection ( state , collectionId ) ) ;
22+ const sorting = useSelector ( ( state ) => state . sorting ) ;
23+ const loading = useSelector ( ( state ) => state . loading ) ;
2924
3025 useEffect ( ( ) => {
3126 dispatch ( CollectionsActions . getCollections ( username ) ) ;
@@ -34,7 +29,7 @@ const Collection = ({ collectionId }) => {
3429
3530 const isOwner = ( ) =>
3631 user != null &&
37- user . username &&
32+ typeof user . username !== 'undefined' &&
3833 collection ?. owner ?. username === user . username ;
3934
4035 const hasCollection = ( ) => ! ! collection ;
@@ -160,7 +155,8 @@ const Collection = ({ collectionId }) => {
160155} ;
161156
162157Collection . propTypes = {
163- collectionId : PropTypes . string . isRequired
158+ collectionId : PropTypes . string . isRequired ,
159+ username : PropTypes . string . isRequired
164160} ;
165161
166162export default Collection ;
0 commit comments