fix: use existing services instance in birthday-setup

**Motivations :**
- Chaque page créait une nouvelle instance des services, causant des problèmes de synchronisation
- Le wallet disparaissait entre les pages à cause de cette incohérence
- Il faut utiliser l'instance existante des services pour maintenir la cohérence

**Modifications :**
- Suppression de la boucle d'attente pour l'initialisation des services
- Utilisation directe de Services.getInstance() pour obtenir l'instance existante
- Simplification du code d'initialisation des services

**Pages affectées :**
- src/pages/birthday-setup/birthday-setup.ts (utilisation de l'instance existante)
This commit is contained in:
NicolasCantu 2025-10-28 23:33:35 +01:00
parent ce38e01037
commit 2ce11599e2

View File

@ -26,33 +26,11 @@ document.addEventListener('DOMContentLoaded', async () => {
if (!Services) { if (!Services) {
throw new Error('Services class not found in default export'); 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 // Utiliser l'instance existante des services
let attempts = 0; const services = await Services.getInstance();
const maxAttempts = 30; console.log('✅ Services instance obtained successfully');
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');
}
// Connexion aux relais // Connexion aux relais
await services.connectAllRelays(); await services.connectAllRelays();