Implement photo favorite for album pages aswell
This commit is contained in:
parent
5d1c2f7134
commit
7686563b28
|
@ -28,6 +28,7 @@ const albumQuery = gql`
|
||||||
highRes {
|
highRes {
|
||||||
url
|
url
|
||||||
}
|
}
|
||||||
|
favorite
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,6 +121,24 @@ export const Photo = ({
|
||||||
}) => {
|
}) => {
|
||||||
const [markFavorite] = useMutation(markFavoriteMutation)
|
const [markFavorite] = useMutation(markFavoriteMutation)
|
||||||
|
|
||||||
|
let heartIcon = null
|
||||||
|
if (typeof photo.favorite == 'boolean') {
|
||||||
|
heartIcon = (
|
||||||
|
<HoverIcon
|
||||||
|
name={photo.favorite ? 'heart' : 'heart outline'}
|
||||||
|
onClick={event => {
|
||||||
|
event.stopPropagation()
|
||||||
|
markFavorite({
|
||||||
|
variables: {
|
||||||
|
photoId: photo.id,
|
||||||
|
favorite: !photo.favorite,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PhotoContainer
|
<PhotoContainer
|
||||||
key={photo.id}
|
key={photo.id}
|
||||||
|
@ -140,18 +158,7 @@ export const Photo = ({
|
||||||
setPresenting(true)
|
setPresenting(true)
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<HoverIcon
|
{heartIcon}
|
||||||
name={photo.favorite ? 'heart' : 'heart outline'}
|
|
||||||
onClick={event => {
|
|
||||||
event.stopPropagation()
|
|
||||||
markFavorite({
|
|
||||||
variables: {
|
|
||||||
photoId: photo.id,
|
|
||||||
favorite: !photo.favorite,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</PhotoOverlay>
|
</PhotoOverlay>
|
||||||
</PhotoContainer>
|
</PhotoContainer>
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue