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:
parent
ce38e01037
commit
2ce11599e2
@ -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();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user