From 73b8d722c2377c7731ea177dafe8bccc70464dc5 Mon Sep 17 00:00:00 2001 From: NicolasCantu Date: Thu, 23 Oct 2025 21:04:35 +0200 Subject: [PATCH] fix: Initialize home page after component creation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit **Motivations :** - Fix blank page after account deletion - Ensure home page is properly initialized when navigating to home - Add proper initialization call after login-4nk-component creation **Modifications :** - Added initHomePage() call after login-4nk-component is added to DOM - Added error handling for home page initialization - Added debug logs to track initialization process **Pages affectées :** - src/router.ts - Added home page initialization in handleLocation --- src/pages/home/home.ts | 16 ++++++++-------- src/router.ts | 10 ++++++++++ 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/pages/home/home.ts b/src/pages/home/home.ts index 71b4f31..df13f02 100755 --- a/src/pages/home/home.ts +++ b/src/pages/home/home.ts @@ -558,22 +558,22 @@ async function handleMainPairing(): Promise { if (mainStatus) { mainStatus.innerHTML = '
Authenticating with browser...'; } - + // Import and trigger WebAuthn directly const { secureCredentialsService } = await import('../../services/secure-credentials.service'); - + // Check if we have existing credentials const hasCredentials = await secureCredentialsService.hasCredentials(); - + if (hasCredentials) { console.log('🔓 Existing credentials found, decrypting...'); if (mainStatus) { mainStatus.innerHTML = '
Decrypting existing credentials...'; } - + // This will trigger WebAuthn for decryption await secureCredentialsService.retrieveCredentials(''); - + if (mainStatus) { mainStatus.innerHTML = '✅ Credentials decrypted successfully'; } @@ -582,15 +582,15 @@ async function handleMainPairing(): Promise { if (mainStatus) { mainStatus.innerHTML = '
Creating new credentials...'; } - + // This will trigger WebAuthn for creation await secureCredentialsService.generateSecureCredentials(''); - + if (mainStatus) { mainStatus.innerHTML = '✅ New credentials created successfully'; } } - + // Now proceed with pairing process await prepareAndSendPairingTx(); diff --git a/src/router.ts b/src/router.ts index 3ea751d..2316209 100755 --- a/src/router.ts +++ b/src/router.ts @@ -55,6 +55,16 @@ async function handleLocation(path: string) { 'width: 100vw; height: 100vh; position: relative; grid-row: 2;' ); if (container) container.appendChild(accountComponent); + + // Initialize the home page after component is added to DOM + console.log('🏠 Initializing home page...'); + try { + const { initHomePage } = await import('./pages/home/home'); + await initHomePage(); + console.log('✅ Home page initialized successfully'); + } catch (error) { + console.error('❌ Failed to initialize home page:', error); + } } else { const html = await fetch(routeHtml).then(data => data.text()); content.innerHTML = html;