From 88efe1a33bf7faaa03d71c2ec87c73f3239c36cf Mon Sep 17 00:00:00 2001 From: Ruidy Nemausat Date: Tue, 2 Jun 2020 14:04:16 +0200 Subject: [PATCH] fix: prevent a user to like a post multiple times --- README.md | 2 +- src/pages/Posts.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9e8e154..d1aec11 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/src/pages/Posts.tsx b/src/pages/Posts.tsx index 4362ff3..f8639ba 100644 --- a/src/pages/Posts.tsx +++ b/src/pages/Posts.tsx @@ -54,7 +54,7 @@ const Posts: FC = ({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));