Skip to content

Commit

Permalink
fix promise
Browse files Browse the repository at this point in the history
  • Loading branch information
ponderingdemocritus committed Dec 20, 2024
1 parent 2c943e7 commit 37d6c17
Showing 1 changed file with 23 additions and 18 deletions.
41 changes: 23 additions & 18 deletions client/src/ui/layouts/World.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -200,24 +200,29 @@ export const World = ({ backgroundImage }: { backgroundImage: string }) => {
}, [structures.length]);

useEffect(() => {
try {
setLoading(LoadingStateKey.Market, true);
setLoading(LoadingStateKey.Bank, true);
console.log("AddToSubscriptionStart - 3");
debouncedAddToSubscription(
dojo.network.toriiClient,
dojo.network.contractComponents as any,
[ADMIN_BANK_ENTITY_ID.toString()],
[],
() => setLoading(LoadingStateKey.Bank, false),
);

debouncedAddMarketSubscription(dojo.network.toriiClient, dojo.network.contractComponents as any, () =>
setLoading(LoadingStateKey.Market, false),
);
} catch (error) {
console.error("Fetch failed", error);
}
const fetch = async () => {
try {
setLoading(LoadingStateKey.Market, true);
setLoading(LoadingStateKey.Bank, true);
console.log("AddToSubscriptionStart - 3");
await Promise.all([
debouncedAddToSubscription(
dojo.network.toriiClient,
dojo.network.contractComponents as any,
[ADMIN_BANK_ENTITY_ID.toString()],
[],
() => setLoading(LoadingStateKey.Bank, false),
),
debouncedAddMarketSubscription(dojo.network.toriiClient, dojo.network.contractComponents as any, () =>
setLoading(LoadingStateKey.Market, false),
),
]);
} catch (error) {
console.error("Fetch failed", error);
}
};

fetch();
}, []);

const battleViewContent = useMemo(
Expand Down

0 comments on commit 37d6c17

Please sign in to comment.