initial drafting of nostr global search fro products

This commit is contained in:
Tiago Vasconcelos 2023-03-10 16:14:23 +00:00
parent b10531763e
commit 469aabc10a
4 changed files with 128 additions and 10 deletions

View file

@ -4,13 +4,47 @@ async function customerMarket(path) {
name: 'customer-market',
template,
props: ['products', 'change-page'],
props: [
'products',
'change-page',
'search-nostr',
'relays',
'update-products',
'update-stalls'
],
data: function () {
return {}
return {
search: null
}
},
methods: {
changePageM(page, opts) {
this.$emit('change-page', page, opts)
},
async searchProducts() {
this.$q.loading.show()
let searchTags = this.search.split(' ')
const pool = new NostrTools.SimplePool()
let relays = Array.from(this.relays)
let merchants = new Set()
let productEvents = await pool.list(relays, [
{
kinds: [30018],
'#t': searchTags,
search: this.search, // NIP50, not very well supported
limit: 100
}
])
productEvents.map(e => merchants.add(e.pubkey))
let stallEvents = await pool.list(relays, [
{
kinds: [30017],
authors: Array.from(merchants)
}
])
await this.$emit('update-data', [...stallEvents, ...productEvents])
this.$q.loading.hide()
}
},
created() {}