mirror of
https://github.com/rjNemo/devbook_ts
synced 2026-06-06 02:36:39 +00:00
fix: prevent a user to like a post multiple times
This commit is contained in:
parent
8ebf904535
commit
88efe1a33b
2 changed files with 2 additions and 2 deletions
|
|
@ -71,7 +71,7 @@ It watches git `master` branch and automatic deploy if the diff passes the tests
|
||||||
|
|
||||||
## Contributing
|
## 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
|
## Versioning
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ const Posts: FC<IProps> = ({posts, firestore, firebase}) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
const post = posts.find(p => p.id === postID);
|
const post = posts.find(p => p.id === postID);
|
||||||
|
|
||||||
if (post) {
|
if (post && id && !post.likes.includes(id)) {
|
||||||
firestore
|
firestore
|
||||||
.update(`${Collections.POSTS}/${post.id}`, {likes: [...post.likes, id]})
|
.update(`${Collections.POSTS}/${post.id}`, {likes: [...post.likes, id]})
|
||||||
.catch(err => console.error(err));
|
.catch(err => console.error(err));
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue