Skip to content

Commit

Permalink
fix comments page (#542)
Browse files Browse the repository at this point in the history
* add number input

* min 0 validation on number

* validate integer

* fix fetch option type user

* fix invalidate key to delete comments
  • Loading branch information
diegoalzate authored May 21, 2024
1 parent 031fa18 commit a85dd82
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 14 deletions.
11 changes: 2 additions & 9 deletions packages/api/src/types/QuestionOptionType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,10 @@ export type QuestionOption = {
updatedAt: string;
questionId: string;
optionTitle: string;
userId?: string;
optionSubTitle?: string;
accepted: boolean;
user: {
group: {
id: string;
name: string;
};
username: string;
firstName?: string;
lastName?: string;
};
fundingRequest: string;
};

export type GetQuestionOptionRequest = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ function CommentsTable({ comment }: CommentsTableProps) {
queryKey: ['commentLikes', comment.id],
queryFn: () => fetchCommentLikes({ commentId: comment.id }),
enabled: !!comment.id,
refetchInterval: 5000, // Poll every 5 seconds
});

useEffect(() => {
Expand Down Expand Up @@ -81,7 +82,7 @@ function CommentsTable({ comment }: CommentsTableProps) {
mutationFn: deleteComment,
onSuccess: (body) => {
if (body) {
queryClient.invalidateQueries({ queryKey: ['comments'] });
queryClient.invalidateQueries({ queryKey: ['option', optionId, 'comments'] });
}
},
});
Expand Down
6 changes: 2 additions & 4 deletions packages/berlin/src/pages/Comments.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,8 @@ function Comments() {
});

const coauthors = useMemo(() => {
return optionUsers?.group?.users?.filter(
(optionUser) => optionUser.username !== option?.user.username,
);
}, [optionUsers, option?.user.username]);
return optionUsers?.group?.users?.filter((optionUser) => optionUser.id !== option?.userId);
}, [optionUsers, option]);

const { data: comments } = useQuery({
queryKey: ['option', optionId, 'comments'],
Expand Down

0 comments on commit a85dd82

Please sign in to comment.