diff --git a/src/pages/birthday-setup/birthday-setup.ts b/src/pages/birthday-setup/birthday-setup.ts index 1e9da8c..91bbf66 100644 --- a/src/pages/birthday-setup/birthday-setup.ts +++ b/src/pages/birthday-setup/birthday-setup.ts @@ -26,33 +26,11 @@ document.addEventListener('DOMContentLoaded', async () => { if (!Services) { throw new Error('Services class not found in default export'); } - console.log('🔄 Waiting for services to be ready...'); + console.log('🔄 Getting existing services instance...'); - // Attendre que les services soient initialisés - let attempts = 0; - const maxAttempts = 30; - const delayMs = 2000; - - let services; - while (attempts < maxAttempts) { - try { - console.log(`🔄 Attempting to get services (attempt ${attempts + 1}/${maxAttempts})...`); - services = await Services.getInstance(); - console.log('✅ Services initialized successfully'); - break; - } catch (error) { - console.log(`⏳ Services not ready yet (attempt ${attempts + 1}/${maxAttempts}):`, (error as Error).message); - attempts++; - if (attempts >= maxAttempts) { - throw new Error(`Services failed to initialize after ${maxAttempts} attempts.`); - } - await new Promise(resolve => setTimeout(resolve, delayMs)); - } - } - - if (!services) { - throw new Error('Services not initialized'); - } + // Utiliser l'instance existante des services + const services = await Services.getInstance(); + console.log('✅ Services instance obtained successfully'); // Connexion aux relais await services.connectAllRelays();