Skip to content

Commit

Permalink
fix overfetching
Browse files Browse the repository at this point in the history
  • Loading branch information
Lamperoyge committed Apr 1, 2024
1 parent e39c07d commit 42b37c4
Showing 1 changed file with 24 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ const DiscordCallbackCmtyUserConnect = () => {
};

const navigate = useNavigate();
const [connectCmtyUser, { loading }] = useMutation(CONNECT_CMTY_USER, {
const [connectCmtyUser, { data, loading, error }] = useMutation(CONNECT_CMTY_USER, {
notifyOnNetworkStatusChange: true,
onCompleted: ({ connectCmtyUser }) => {
setFinishedVerification(true);
if (connectCmtyUser?.token) {
Expand All @@ -66,13 +67,12 @@ const DiscordCallbackCmtyUserConnect = () => {
},
onError: (err) => {
setFinishedVerification(true);
// const message = err?.graphQLErrors[0]?.extensions?.message;
// return handleError(message);
handleError(err?.graphQLErrors[0]?.extensions?.message);
},
});

useEffect(() => {
if (code && !loading && (questId || referralCode)) {
if (code && !loading && (questId || referralCampaignExternalId) && !data && !error) {
connectCmtyUser({
variables: {
code,
Expand All @@ -81,28 +81,29 @@ const DiscordCallbackCmtyUserConnect = () => {
},
});
}
}, [code, loading, questId, referralCampaignExternalId]);
}, [loading, data, error]);

return (
<Grid display="flex" flexDirection="column" height="100%" minHeight="100vh">
<Grid flex="2" display="flex" justifyContent="center" alignItems="center" gap="8px" flexDirection="column">
{finishedVerification && (
<Typography fontFamily="Poppins" fontWeight={600} fontSize="18px" lineHeight="24px" color="black">
Finished connecting your Discord! You can close this window now and return to previous tab.
</Typography>
)}
{!finishedVerification && <Spinner />}
<Grid flex="2" display="flex" justifyContent="center" alignItems="center" gap="8px" flexDirection="column">
{finishedVerification && (
<Typography fontFamily="Poppins" fontWeight={600} fontSize="18px" lineHeight="24px" color="black">
Finished connecting your Discord! You can close this window now and return to previous tab.
</Typography>
)}
{!finishedVerification && <Spinner />}
</Grid>
<Grid
flex="1"
sx={{
backgroundImage: "url(/images/home-bg.png)",
backgroundPosition: "bottom",
backgroundRepeat: "no-repeat",
backgroundSize: "cover",
}}
position="relative"
></Grid>
</Grid>
<Grid
flex="1"
sx={{
backgroundImage: "url(/images/home-bg.png)",
backgroundPosition: "bottom",
backgroundRepeat: "no-repeat",
backgroundSize: "cover",
}}
position="relative"
></Grid>
</Grid>
);
};

Expand Down

0 comments on commit 42b37c4

Please sign in to comment.