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 { highRes {
url url
} }
favorite
} }
} }
} }

View File

@ -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>
) )