Skip to content

Commit 52e957b

Browse files
committed
Fix: Prevent article page from calling bookmarks for unauthenticated users (#1138)
1 parent 77aa243 commit 52e957b

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

components/ArticlePreview/ArticlePreview.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,13 @@ const ArticlePreview: NextPage<Props> = ({
5555
showBookmark = true,
5656
bookmarkedInitialState = false,
5757
}) => {
58+
const { data: session } = useSession();
5859
const [bookmarked, setIsBookmarked] = useState(bookmarkedInitialState);
5960
const howManySavedToShow = 3;
60-
const { data: bookmarksData, refetch } = api.post.myBookmarks.useQuery({
61-
limit: howManySavedToShow,
62-
});
63-
const { data: session } = useSession();
61+
const { data: bookmarksData, refetch } = api.post.myBookmarks.useQuery(
62+
{ limit: howManySavedToShow },
63+
{ enabled: !!session }
64+
);
6465
const bookmarks = bookmarksData?.bookmarks;
6566
const dateTime = Temporal.Instant.from(new Date(date).toISOString());
6667
const readableDate = dateTime.toLocaleString(["en-IE"], {

0 commit comments

Comments
 (0)