From bec3ab1729f2157a48a72e86711340fbeefed251 Mon Sep 17 00:00:00 2001 From: NicolasCantu Date: Thu, 23 Oct 2025 19:02:42 +0200 Subject: [PATCH] fix: Improve relay readiness logic and prevent iframe initialization in full page MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit **Motivations :** - Fix 'Waiting for relays to be ready...' issue by properly waiting for relay spAddress - Prevent unnecessary iframe creation when application runs in full page mode - Improve relay address validation logic **Modifications :** - Enhanced createProcess to properly wait for relay spAddress before proceeding - Added better relay address validation with non-empty string check - Conditional iframe initialization only when running in iframe context - Added debug logging for available relays when address not found **Pages affectées :** - src/services/service.ts - Relay readiness logic - src/pages/home/home.ts - Conditional iframe initialization --- src/pages/home/home.ts | 10 ++++++---- src/services/service.ts | 25 ++++++++++++++----------- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src/pages/home/home.ts b/src/pages/home/home.ts index bd77683..04a545d 100755 --- a/src/pages/home/home.ts +++ b/src/pages/home/home.ts @@ -108,10 +108,12 @@ export async function initHomePage(): Promise { // Show loading spinner during home page initialization showHomeLoadingSpinner('Initializing pairing interface...'); - // Initialize iframe pairing, content menu, and communication - initIframePairing(); - initContentMenu(); - initIframeCommunication(); + // Initialize iframe pairing, content menu, and communication only if in iframe + if (window.parent !== window) { + initIframePairing(); + initContentMenu(); + initIframeCommunication(); + } // Set up iframe pairing button listeners setupIframePairingButtons(); diff --git a/src/services/service.ts b/src/services/service.ts index 102eec2..077bf7f 100755 --- a/src/services/service.ts +++ b/src/services/service.ts @@ -829,22 +829,25 @@ export default class Services { publicData: Record, roles: Record ): Promise { - let relayAddress = this.getAllRelays()[0]?.spAddress; - - if (!relayAddress) { - console.log('⏳ Waiting for relays to be ready...'); - // Update UI status - const { updateCreatorStatus } = await import('../utils/sp-address.utils'); - updateCreatorStatus('⏳ Waiting for relays to be ready...'); - - await this.getRelayReadyPromise(); - relayAddress = this.getAllRelays()[0]?.spAddress; - } + // Attendre que le relai soit prêt avec son spAddress + console.log('⏳ Waiting for relays to be ready...'); + // Update UI status + const { updateCreatorStatus } = await import('../utils/sp-address.utils'); + updateCreatorStatus('⏳ Waiting for relays to be ready...'); + + await this.getRelayReadyPromise(); + + // Vérifier que nous avons maintenant un spAddress + const relays = this.getAllRelays(); + const relayAddress = relays.find(relay => relay.spAddress && relay.spAddress.trim() !== '')?.spAddress; if (!relayAddress) { + console.error('Available relays:', relays); throw new Error('❌ No relay address available after waiting'); } + console.log('✅ Relay address found:', relayAddress); + const feeRate = 1; // We can't encode files as the rest because Uint8Array is not valid json