Skip to content

Commit

Permalink
Fix: Prevent article page from calling bookmarks for unauthenticated …
Browse files Browse the repository at this point in the history
…users (#1138) (#1165)

* Fix: Prevent article page from calling bookmarks for unauthenticated users (#1138)
  • Loading branch information
shanksxz authored Oct 21, 2024
1 parent 5961ea6 commit cffa5e3
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions components/ArticlePreview/ArticlePreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,13 @@ const ArticlePreview: NextPage<Props> = ({
showBookmark = true,
bookmarkedInitialState = false,
}) => {
const { data: session } = useSession();
const [bookmarked, setIsBookmarked] = useState(bookmarkedInitialState);
const howManySavedToShow = 3;
const { data: bookmarksData, refetch } = api.post.myBookmarks.useQuery({
limit: howManySavedToShow,
});
const { data: session } = useSession();
const { data: bookmarksData, refetch } = api.post.myBookmarks.useQuery(
{ limit: howManySavedToShow },
{ enabled: !!session },
);
const bookmarks = bookmarksData?.bookmarks;
const dateTime = Temporal.Instant.from(new Date(date).toISOString());
const readableDate = dateTime.toLocaleString(["en-IE"], {
Expand Down

0 comments on commit cffa5e3

Please sign in to comment.