diff --git a/src/pages/birthday-setup/birthday-setup.html b/src/pages/birthday-setup/birthday-setup.html index 3575584..d3ca84b 100644 --- a/src/pages/birthday-setup/birthday-setup.html +++ b/src/pages/birthday-setup/birthday-setup.html @@ -112,7 +112,7 @@
- + diff --git a/src/pages/birthday-setup/birthday-setup.ts b/src/pages/birthday-setup/birthday-setup.ts index 24ca486..1e9da8c 100644 --- a/src/pages/birthday-setup/birthday-setup.ts +++ b/src/pages/birthday-setup/birthday-setup.ts @@ -67,22 +67,26 @@ document.addEventListener('DOMContentLoaded', async () => { // Attendre que la hauteur de bloc soit définie avant de mettre à jour la date anniversaire updateStatus('⏳ Attente de la synchronisation avec le réseau...', 'loading'); - let blockHeightAttempts = 0; - const blockHeightMaxAttempts = 100; // Augmenter à 100 tentatives (10 secondes) - while (blockHeightAttempts < blockHeightMaxAttempts) { - const blockHeight = services.getCurrentBlockHeight(); - if (blockHeight !== -1) { - console.log(`✅ Block height set: ${blockHeight}`); - break; - } - console.log(`⏳ Waiting for block height (attempt ${blockHeightAttempts + 1}/${blockHeightMaxAttempts})...`); - await new Promise(resolve => setTimeout(resolve, 100)); - blockHeightAttempts++; - } + + // Attendre que la hauteur de bloc soit définie via le handshake + await new Promise((resolve, reject) => { + const timeout = setTimeout(() => { + reject(new Error('Timeout waiting for block height')); + }, 15000); // 15 secondes de timeout - if (services.getCurrentBlockHeight() === -1) { - throw new Error('Failed to get block height from relay'); - } + const checkBlockHeight = () => { + const blockHeight = services.getCurrentBlockHeight(); + if (blockHeight !== -1) { + console.log(`✅ Block height set: ${blockHeight}`); + clearTimeout(timeout); + resolve(); + } else { + setTimeout(checkBlockHeight, 100); + } + }; + + checkBlockHeight(); + }); // Mettre à jour la date anniversaire du wallet await services.updateDeviceBlockHeight();