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:
parent
02371fe05d
commit
ca3930296b
1 changed files with 8 additions and 20 deletions
|
|
@ -170,14 +170,12 @@ export function useMarket() {
|
||||||
try {
|
try {
|
||||||
const client = nostrStore.getClient()
|
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
|
// Fetch all stall events from all authors
|
||||||
// Note: We need to fetch all stalls and then filter by the ones that belong to this market
|
// We'll filter by market membership in the application logic
|
||||||
// since stalls don't have a direct market association in their tags
|
|
||||||
const events = await client.fetchEvents({
|
const events = await client.fetchEvents({
|
||||||
kinds: [MARKET_EVENT_KINDS.STALL],
|
kinds: [MARKET_EVENT_KINDS.STALL]
|
||||||
authors: [marketPubkey]
|
|
||||||
})
|
})
|
||||||
|
|
||||||
console.log('Found stall events:', events.length)
|
console.log('Found stall events:', events.length)
|
||||||
|
|
@ -237,23 +235,13 @@ export function useMarket() {
|
||||||
try {
|
try {
|
||||||
const client = nostrStore.getClient()
|
const client = nostrStore.getClient()
|
||||||
|
|
||||||
// Get all stall pubkeys
|
// Fetch all product events from all authors
|
||||||
const stallPubkeys = marketStore.stalls.map(stall => stall.pubkey)
|
// We'll filter by stall membership in the application logic
|
||||||
|
|
||||||
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
|
|
||||||
const events = await client.fetchEvents({
|
const events = await client.fetchEvents({
|
||||||
kinds: [MARKET_EVENT_KINDS.PRODUCT],
|
kinds: [MARKET_EVENT_KINDS.PRODUCT]
|
||||||
authors: stallPubkeys
|
|
||||||
})
|
})
|
||||||
|
|
||||||
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
|
// Group events by product ID and keep only the most recent version
|
||||||
const productGroups = new Map<string, any[]>()
|
const productGroups = new Map<string, any[]>()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue