Skip to content

Commit

Permalink
Merge pull request #52 from superhero-com/fix/reload-loop
Browse files Browse the repository at this point in the history
fix: reload loop on signup
  • Loading branch information
kenodressel authored Jan 30, 2024
2 parents 4b2e1a4 + 88eab51 commit 660fe92
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions src/context/SuperheroProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,19 @@ import { communityBotAtom, minimumTokenThresholdAtom, verifiedAccountsAtom, veri

const useMinimumTokenThreshold = (config: any): void => {
const [, setMinimumTokenThreshold] = useAtom(minimumTokenThresholdAtom);
const [isLoading, setIsLoading] = React.useState(false);

const loadMinimumTokenThreshold = useCallback(() => {
if (config.bots_backend_url && !isLoading) {
setIsLoading(true);
if (config.bots_backend_url) {
fetch(`${config.bots_backend_url}/ui/minimum-token-threshold`, {
method: "GET",
})
.then((res) => res.json())
.then(setMinimumTokenThreshold)
.catch((e) => {
console.error("Error loading minimum token threshold", e);
})
.finally(() => {
setIsLoading(false);
});
}
}, [config.bots_backend_url, isLoading, setMinimumTokenThreshold]);
}, [setMinimumTokenThreshold, config.bots_backend_url]);

useEffect(() => {
loadMinimumTokenThreshold();
Expand Down

0 comments on commit 660fe92

Please sign in to comment.