@@ -13,19 +13,16 @@ 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, collection, sorting, loading } = useSelector ( ( state ) => ( {
21
+ user : state . user ,
22
+ collection : getCollection ( state , collectionId ) ,
23
+ sorting : state . sorting ,
24
+ loading : state . loading
25
+ } ) ) ;
29
26
30
27
useEffect ( ( ) => {
31
28
dispatch ( CollectionsActions . getCollections ( username ) ) ;
@@ -34,7 +31,7 @@ const Collection = ({ collectionId }) => {
34
31
35
32
const isOwner = ( ) =>
36
33
user != null &&
37
- user . username &&
34
+ typeof user . username !== 'undefined' &&
38
35
collection ?. owner ?. username === user . username ;
39
36
40
37
const hasCollection = ( ) => ! ! collection ;
@@ -160,7 +157,8 @@ const Collection = ({ collectionId }) => {
160
157
} ;
161
158
162
159
Collection . propTypes = {
163
- collectionId : PropTypes . string . isRequired
160
+ collectionId : PropTypes . string . isRequired ,
161
+ username : PropTypes . string . isRequired
164
162
} ;
165
163
166
164
export default Collection ;
0 commit comments