Skip to content

Commit

Permalink
fix: dont request unread count when logged out
Browse files Browse the repository at this point in the history
  • Loading branch information
ImLunaHey committed Jan 9, 2025
1 parent 09b8f20 commit 12b58fe
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/lib/bluesky/hooks/useUnreadCount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ import { useBlueskyStore } from '../store';

export function useUnreadCount() {
const agent = useBlueskyStore((store) => store.agent);
const isAuthenticated = useBlueskyStore((store) => store.isAuthenticated);

return useQuery({
queryKey: ['unread-count'],
queryFn: async () => {
const response = await agent.api.app.bsky.notification.getUnreadCount();
return response.data.count;
},
enabled: !!agent,
enabled: !!agent && isAuthenticated,
// refetch every 10 seconds since we don't have a websocket connection
refetchInterval: 10_000,
initialData: 0,
Expand Down

0 comments on commit 12b58fe

Please sign in to comment.