Skip to content

Commit

Permalink
fix: correct write for upvote
Browse files Browse the repository at this point in the history
  • Loading branch information
thraizz committed Jan 26, 2024
1 parent fa016fd commit ed039b0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export type User = {

// Project Type
export type Project = {
_id: string;
projectId: string;
userId: string; // owner's user ID
title: string;
Expand Down
2 changes: 1 addition & 1 deletion src/views/ProjectsList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ onMounted(async () => {
projects.value = querySnapshot.docs.map(
(doc) =>
({
projectId: doc.id,
_id: doc.id,
...doc.data(),
}) as Project,
);
Expand Down
6 changes: 4 additions & 2 deletions src/views/UpvoteButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ const props = defineProps<{
}>();
const { user } = useUser();
const upvoteProject = () => {
setDoc(doc(db, `projects/${props.project.projectId}`), {
setDoc(doc(db, `projects/${props.project._id}`), {
...props.project,
upvotes: user.value
? [...props.project.upvotes, user.value.uid]
? props.project.upvotes.includes(user.value.uid)
? props.project.upvotes.filter((uid) => uid !== user.value?.uid)
: [...props.project.upvotes, user.value.uid]
: props.project.upvotes,
})
.then(() => {
Expand Down

0 comments on commit ed039b0

Please sign in to comment.