1
Fork 0

Implement photo favorite for album pages aswell

This commit is contained in:
viktorstrate 2020-06-19 15:38:27 +02:00
parent 5d1c2f7134
commit 7686563b28
2 changed files with 20 additions and 12 deletions

View File

@ -28,6 +28,7 @@ const albumQuery = gql`
highRes {
url
}
favorite
}
}
}

View File

@ -121,6 +121,24 @@ export const Photo = ({
}) => {
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 (
<PhotoContainer
key={photo.id}
@ -140,18 +158,7 @@ export const Photo = ({
setPresenting(true)
}}
/>
<HoverIcon
name={photo.favorite ? 'heart' : 'heart outline'}
onClick={event => {
event.stopPropagation()
markFavorite({
variables: {
photoId: photo.id,
favorite: !photo.favorite,
},
})
}}
/>
{heartIcon}
</PhotoOverlay>
</PhotoContainer>
)