Skip to content

Commit

Permalink
feat: fixed multiple wallet popups, decreased graphql UI update interval
Browse files Browse the repository at this point in the history
  • Loading branch information
rishabhkeshan committed Oct 28, 2024
1 parent 349dc24 commit 9f44514
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 30 deletions.
26 changes: 0 additions & 26 deletions frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,39 +28,13 @@ function App() {
);
const { isConnected } = useIsConnected();
const { wallet } = useWallet();
const { assets } = useAssets();
const { addAssets } = useAddAssets();

useEffect(() => {
const userAgent = navigator.userAgent.toLowerCase();
const mobile = /(iphone|android|windows phone)/.test(userAgent);
setIsMobile(mobile);
}, []);

useEffect(() => {
async function getAccounts() {
if (mounted) {
let hasAsset = false;
for (let i = 0; i < assets.length; i++) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const thisAsset = assets[i] as any;
if (thisAsset.assetId && thisAsset.assetId === farmCoinAssetID) {
hasAsset = true;
break;
}
if (!hasAsset) {
addAssets([FARM_COIN_ASSET]);
}
}
} else {
setMounted(true);
}
}
// if wallet is installed & connected, fetch account info
if (isConnected) getAccounts();

}, [isConnected, mounted]);

const contract = useMemo(() => {
if (wallet) {
const contract = new FarmContract(CONTRACT_ID, wallet);
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/Game.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export default function Game({
// fetches player info 30 seconds
const interval = setInterval(() => {
setUpdateNum(updateNum + 1);
}, 30000);
}, 10000);

return () => clearInterval(interval);
}, [contract, updateNum]);
Expand All @@ -111,7 +111,7 @@ export default function Game({
setUpdateNum(updateNum + 1);
setTimeout(() => {
setUpdateNum(updateNum + 1);
}, 250);
}, 2000);
};

const controlsMap = useMemo<KeyboardControlsEntry[]>(
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import {
BakoSafeConnector,
BurnerWalletConnector,
createConfig as createFuelConfig,
FueletWalletConnector,
FuelWalletConnector,
SolanaConnector,
WalletConnectConnector,
defaultConnectors
} from "@fuels/connectors";import { FuelProvider } from "@fuels/react";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { Provider, CHAIN_IDS } from "fuels";
Expand Down

0 comments on commit 9f44514

Please sign in to comment.