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.
This commit is contained in:
padreug 2025-08-05 00:57:31 +02:00
parent 02371fe05d
commit ca3930296b

View file

@ -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<string, any[]>()