Skip to content

Commit

Permalink
debug
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-vahn committed Apr 22, 2024
1 parent f020e58 commit f19c88a
Showing 1 changed file with 36 additions and 36 deletions.
72 changes: 36 additions & 36 deletions src/components/connectOverlay/ConnectOverlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const BRIDGE_URL = import.meta.env.VITE_BRIDGE_URL || '';
const ConnectOverlay: React.FC<Props> = ({
slideAnimation,
close,
// onConnect,
onConnect,
}) => {
const [networksExpanded, setNetworksExpanded] = useState(true);
const [walletsExpanded, setWalletsExpanded] = useState(false);
Expand All @@ -49,46 +49,46 @@ const ConnectOverlay: React.FC<Props> = ({
console.log(BRIDGE_URL);

const response = await axios.post(BRIDGE_URL + '/init-provider');
// const providerId = response.data.providerId;
const providerId = response.data.providerId;
WebApp.openLink(response.data.universalLink);
close();

// const startTime = Date.now(); // Record start time
// const timeout = 30000; // 30 seconds timeout
const startTime = Date.now(); // Record start time
const timeout = 30000; // 30 seconds timeout

// Function to check connection status
// const checkConnection = async () => {
// if (Date.now() - startTime > timeout) {
// return;
// }

// try {
// const statusResponse = await axios.post(
// BRIDGE_URL + '/is-connected',
// {
// providerId: providerId,
// withCredentials: true,
// headers: {
// 'Content-Type': 'application/json',
// 'Access-Control-Allow-Origin': '*',
// 'ngrok-skip-browser-warning': 'true',
// },
// }
// );
// if (statusResponse.data.connected) {
// onConnect();
// } else {
// console.log('Not Connected, checking again...');
// setTimeout(checkConnection, 1000);
// }
// } catch (error) {
// console.error('Error checking connection:', error);
// setTimeout(checkConnection, 1000);
// }
// };

// // Start checking connection status
// checkConnection();
const checkConnection = async () => {
if (Date.now() - startTime > timeout) {
return;
}

try {
const statusResponse = await axios.post(
BRIDGE_URL + '/is-connected',
{
providerId: providerId,
withCredentials: true,
headers: {
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': '*',
'ngrok-skip-browser-warning': 'true',
},
}
);
if (statusResponse.data.connected) {
onConnect();
} else {
console.log('Not Connected, checking again...');
setTimeout(checkConnection, 1000);
}
} catch (error) {
console.error('Error checking connection:', error);
setTimeout(checkConnection, 1000);
}
};

// Start checking connection status
checkConnection();
} catch (error) {
console.error('Error during initial connection:', error);
}
Expand Down

0 comments on commit f19c88a

Please sign in to comment.