diff --git a/src/pages/birthday-setup/birthday-setup.ts b/src/pages/birthday-setup/birthday-setup.ts index 8cd99f4..99daf96 100644 --- a/src/pages/birthday-setup/birthday-setup.ts +++ b/src/pages/birthday-setup/birthday-setup.ts @@ -64,15 +64,28 @@ document.addEventListener('DOMContentLoaded', async () => { return; } - // Vérifier que le wallet existe en base - const wallet = await services.getDeviceFromDatabase(); + // Vérifier que le wallet existe en base (avec plusieurs tentatives pour gérer les problèmes de synchronisation) + let wallet = await services.getDeviceFromDatabase(); if (!wallet) { - console.log('⚠️ Wallet not found, redirecting to wallet-setup...'); - updateStatus('⚠️ Redirection vers la configuration du wallet...', 'loading'); - setTimeout(() => { - window.location.href = '/src/pages/wallet-setup/wallet-setup.html'; - }, 1000); - return; + console.log('⚠️ Wallet not found, waiting for database synchronization...'); + // Attendre un peu pour la synchronisation de la base de données + for (let attempt = 0; attempt < 5; attempt++) { + await new Promise(resolve => setTimeout(resolve, 500)); + wallet = await services.getDeviceFromDatabase(); + if (wallet) { + console.log(`✅ Wallet found after ${attempt + 1} attempts`); + break; + } + } + + if (!wallet) { + console.log('⚠️ Wallet still not found after retries, redirecting to wallet-setup...'); + updateStatus('⚠️ Redirection vers la configuration du wallet...', 'loading'); + setTimeout(() => { + window.location.href = '/src/pages/wallet-setup/wallet-setup.html'; + }, 1000); + return; + } } console.log('✅ Wallet found in database'); console.log('✅ All prerequisites verified');