From ca3930296bf482b2a1e40138a9eb7ac2fa76dc0b Mon Sep 17 00:00:00 2001 From: padreug Date: Tue, 5 Aug 2025 00:57:31 +0200 Subject: [PATCH] refactor: Update event fetching logic in useMarket composable - Modify the event fetching process to retrieve all stalls and products from all authors instead of filtering by market and stall pubkeys directly. - Enhance logging to reflect the broader scope of data being loaded, improving clarity in the console output. - Adjust comments to clarify the application logic for filtering events based on market and stall membership. --- src/composables/useMarket.ts | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/src/composables/useMarket.ts b/src/composables/useMarket.ts index 5cb6c8d..e494f0e 100644 --- a/src/composables/useMarket.ts +++ b/src/composables/useMarket.ts @@ -170,14 +170,12 @@ export function useMarket() { try { const client = nostrStore.getClient() - console.log('Loading stalls for market pubkey:', marketPubkey) + console.log('Loading all stalls from all authors') - // Fetch stall events for this market - // Note: We need to fetch all stalls and then filter by the ones that belong to this market - // since stalls don't have a direct market association in their tags + // Fetch all stall events from all authors + // We'll filter by market membership in the application logic const events = await client.fetchEvents({ - kinds: [MARKET_EVENT_KINDS.STALL], - authors: [marketPubkey] + kinds: [MARKET_EVENT_KINDS.STALL] }) console.log('Found stall events:', events.length) @@ -237,23 +235,13 @@ export function useMarket() { try { const client = nostrStore.getClient() - // Get all stall pubkeys - const stallPubkeys = marketStore.stalls.map(stall => stall.pubkey) - - console.log('Loading products for stall pubkeys:', stallPubkeys) - - if (stallPubkeys.length === 0) { - console.log('No stalls found, skipping product loading') - return - } - - // Fetch product events from all stalls + // Fetch all product events from all authors + // We'll filter by stall membership in the application logic const events = await client.fetchEvents({ - kinds: [MARKET_EVENT_KINDS.PRODUCT], - authors: stallPubkeys + kinds: [MARKET_EVENT_KINDS.PRODUCT] }) - console.log('Found product events:', events.length) + console.log('Found product events from all authors:', events.length) // Group events by product ID and keep only the most recent version const productGroups = new Map()