fix: prevent a user to like a post multiple times

This commit is contained in:
Ruidy Nemausat 2020-06-02 14:04:16 +02:00
parent 8ebf904535
commit 88efe1a33b
2 changed files with 2 additions and 2 deletions

View file

@ -71,7 +71,7 @@ It watches git `master` branch and automatic deploy if the diff passes the tests
## Contributing
Please read [CONTRIBUTING.md](https://github.com/rjNemo/devbook_ts/CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests to us.
Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests to us.
## Versioning

View file

@ -54,7 +54,7 @@ const Posts: FC<IProps> = ({posts, firestore, firebase}) => {
e.preventDefault();
const post = posts.find(p => p.id === postID);
if (post) {
if (post && id && !post.likes.includes(id)) {
firestore
.update(`${Collections.POSTS}/${post.id}`, {likes: [...post.likes, id]})
.catch(err => console.error(err));