Skip to content

Commit

Permalink
Merge pull request #2242 from wondrous-dev/fix/overfetching
Browse files Browse the repository at this point in the history
fix overfetching
  • Loading branch information
Lamperoyge authored Apr 1, 2024
2 parents e39c07d + 42b37c4 commit abfa012
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 abfa012

Please sign in to comment.