@@ -13,19 +13,14 @@ import ArrowDownIcon from '../../../images/sort-arrow-down.svg';
13
13
import CollectionMetadata from './CollectionMetadata' ;
14
14
import CollectionItemRow from './CollectionItemRow' ;
15
15
16
- const Collection = ( { collectionId } ) => {
16
+ const Collection = ( { collectionId, username } ) => {
17
17
const { t } = useTranslation ( ) ;
18
18
const dispatch = useDispatch ( ) ;
19
19
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 ) ;
29
24
30
25
useEffect ( ( ) => {
31
26
dispatch ( CollectionsActions . getCollections ( username ) ) ;
@@ -34,7 +29,7 @@ const Collection = ({ collectionId }) => {
34
29
35
30
const isOwner = ( ) =>
36
31
user != null &&
37
- user . username &&
32
+ typeof user . username !== 'undefined' &&
38
33
collection ?. owner ?. username === user . username ;
39
34
40
35
const hasCollection = ( ) => ! ! collection ;
@@ -160,7 +155,8 @@ const Collection = ({ collectionId }) => {
160
155
} ;
161
156
162
157
Collection . propTypes = {
163
- collectionId : PropTypes . string . isRequired
158
+ collectionId : PropTypes . string . isRequired ,
159
+ username : PropTypes . string . isRequired
164
160
} ;
165
161
166
162
export default Collection ;
0 commit comments