Hey is a decentralized and permissionless social media app built with Lens Protocol 🌿

feat: update CreatorCoin component to fetch current account details and display success toast on address update

yoginth.com 7d0a7699 75a391bb

verified
+12 -4
+12 -4
apps/web/src/components/Settings/Pro/CreatorCoin.tsx
··· 1 - import { ZORA_API_KEY } from "@hey/data/constants"; 1 + import { MeVariables, ZORA_API_KEY } from "@hey/data/constants"; 2 2 import { Regex } from "@hey/data/regex"; 3 - import { useSetAccountMetadataMutation } from "@hey/indexer"; 3 + import { useMeLazyQuery, useSetAccountMetadataMutation } from "@hey/indexer"; 4 4 import type { ApolloClientError } from "@hey/types/errors"; 5 5 import { account as accountMetadata } from "@lens-protocol/metadata"; 6 6 import { useQuery } from "@tanstack/react-query"; 7 7 import { type GetCoinResponse, getCoin, setApiKey } from "@zoralabs/coins-sdk"; 8 8 import { useCallback, useEffect, useState } from "react"; 9 + import { toast } from "sonner"; 9 10 import { base } from "viem/chains"; 10 11 import { z } from "zod"; 11 12 import MetaDetails from "@/components/Account/MetaDetails"; ··· 35 36 }); 36 37 37 38 const CreatorCoin = () => { 38 - const { currentAccount } = useAccountStore(); 39 + const { currentAccount, setCurrentAccount } = useAccountStore(); 39 40 const [isSubmitting, setIsSubmitting] = useState(false); 40 41 const handleTransactionLifecycle = useTransactionLifecycle(); 41 42 const waitForTransactionToComplete = useWaitForTransactionToComplete(); 43 + const [getCurrentAccountDetails] = useMeLazyQuery({ 44 + fetchPolicy: "no-cache", 45 + variables: MeVariables 46 + }); 42 47 43 48 const onCompleted = async (hash: string) => { 44 49 await waitForTransactionToComplete(hash); 45 - location.reload(); 50 + const accountData = await getCurrentAccountDetails(); 51 + setCurrentAccount(accountData?.data?.me.loggedInAs.account); 52 + setIsSubmitting(false); 53 + toast.success("Creator coin address updated"); 46 54 }; 47 55 48 56 const onError = useCallback((error: ApolloClientError) => {