Skip to content

Commit

Permalink
Only go to network for thread count if sidebar is closed
Browse files Browse the repository at this point in the history
This way there are not two requests in flight for the same info
  • Loading branch information
CarsonF committed Oct 10, 2024
1 parent c413b0b commit 0b4310b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/components/Comments/ToggleCommentButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ export type ToggleCommentsButtonProps = Except<IconButtonProps, 'children'>;
export const ToggleCommentsButton = ({
...rest
}: ToggleCommentsButtonProps) => {
const { resourceId, toggleCommentsBar } = useCommentsContext();
const { resourceId, isCommentsBarOpen, toggleCommentsBar } =
useCommentsContext();

const { data } = useQuery(ThreadCountDocument, {
variables: { id: resourceId! },
skip: !resourceId,
fetchPolicy: isCommentsBarOpen ? 'cache-only' : 'cache-first',
});
const total = data?.commentable.commentThreads.total ?? 0;

Expand Down

0 comments on commit 0b4310b

Please sign in to comment.