repo_description: Hey is a decentralized and permissionless social media app built with Lens Protocol 🌿
repo_topics: blockchain crypto dapp graphql hacktoberfest lens-protocol nextjs react social-media tailwindcss turborepo typescript vitest wagmi web3
code: import {
    NotificationOrderBy,
    useNotificationIndicatorQuery
  } from "@/indexer/generated";
  import { useAccountStore } from "@/store/persisted/useAccountStore";
  import { useNotificationStore } from "@/store/persisted/useNotificationStore";
  
  const useHasNewNotifications = () => {
    const { currentAccount } = useAccountStore();
    const { lastSeenNotificationId } = useNotificationStore();
  
    const { data } = useNotificationIndicatorQuery({
      skip: !currentAccount,
      variables: { request: { orderBy: NotificationOrderBy.Default } }
    });
  
    const latestNotificationWithId = data?.notifications?.items?.find(
      (notification) => "id" in notification
    );
    const latestId = latestNotificationWithId?.id;
  
    if (!latestId || !currentAccount) {
      return false;
    }
  
    return latestId !== lastSeenNotificationId;
  };
  
  export default useHasNewNotifications;
  