chore: code clean-up
This commit is contained in:
parent
e1fd62400d
commit
8ebe2fe458
4 changed files with 5 additions and 63 deletions
|
|
@ -1,26 +1,4 @@
|
||||||
<div>
|
<div>
|
||||||
<div v-if="searchNostr" class="row q-col-gutter-md">
|
|
||||||
<div class="col-12 q-gutter-y-md">
|
|
||||||
<q-card>
|
|
||||||
<q-card-section>
|
|
||||||
<div class="row items-center no-wrap q-mb-md">
|
|
||||||
<div class="col">
|
|
||||||
<h5 class="text-subtitle1 q-my-none">Search Globally</h5>
|
|
||||||
<p>Search for products on Nostr</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</q-card-section>
|
|
||||||
<q-card-section>
|
|
||||||
<q-input class="q-ml-md" standout square dense outlined clearable v-model.trim="search"
|
|
||||||
label="Search products" @keydown.enter="searchProducts" hint="Enter search terms separated by spaces">
|
|
||||||
<template v-slot:after>
|
|
||||||
<q-btn dense flat icon="search" label="Search" @click="searchProducts" />
|
|
||||||
</template>
|
|
||||||
</q-input>
|
|
||||||
</q-card-section>
|
|
||||||
</q-card>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<q-infinite-scroll v-if="showProducts" @load="onLoad" :offset="250">
|
<q-infinite-scroll v-if="showProducts" @load="onLoad" :offset="250">
|
||||||
|
|
|
||||||
|
|
@ -4,17 +4,7 @@ async function customerMarket(path) {
|
||||||
name: 'customer-market',
|
name: 'customer-market',
|
||||||
template,
|
template,
|
||||||
|
|
||||||
props: [
|
props: ['filtered-products', 'search-text', 'filter-categories'],
|
||||||
'filtered-products',
|
|
||||||
'change-page',
|
|
||||||
'search-nostr',
|
|
||||||
'relays',
|
|
||||||
'update-products',
|
|
||||||
'update-stalls',
|
|
||||||
|
|
||||||
'search-text',
|
|
||||||
'filter-categories'
|
|
||||||
],
|
|
||||||
data: function () {
|
data: function () {
|
||||||
return {
|
return {
|
||||||
search: null,
|
search: null,
|
||||||
|
|
@ -54,33 +44,7 @@ async function customerMarket(path) {
|
||||||
changePageM(page, opts) {
|
changePageM(page, opts) {
|
||||||
this.$emit('change-page', 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)
|
|
||||||
}
|
|
||||||
])
|
|
||||||
pool.close(relays)
|
|
||||||
await this.$emit('update-data', [...stallEvents, ...productEvents])
|
|
||||||
this.$q.loading.hide()
|
|
||||||
},
|
|
||||||
onLoad(_, done) {
|
onLoad(_, done) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (this.startIndex >= this.filteredProducts.length) {
|
if (this.startIndex >= this.filteredProducts.length) {
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,7 @@ const market = async () => {
|
||||||
show: false
|
show: false
|
||||||
},
|
},
|
||||||
|
|
||||||
searchNostr: false,
|
|
||||||
filterCategories: [],
|
filterCategories: [],
|
||||||
groupByStall: false,
|
groupByStall: false,
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -188,9 +188,9 @@
|
||||||
<customer-stall-list v-if="groupByStall" :stalls="filterStalls"
|
<customer-stall-list v-if="groupByStall" :stalls="filterStalls"
|
||||||
@change-page="navigateTo"></customer-stall-list>
|
@change-page="navigateTo"></customer-stall-list>
|
||||||
|
|
||||||
<customer-market v-else :search-nostr="searchNostr" :relays="relays" :filtered-products="filterProducts"
|
<customer-market v-else :filtered-products="filterProducts" :search-text="searchText"
|
||||||
:search-text="searchText" :filter-categories="filterCategories" @change-page="navigateTo"
|
:filter-categories="filterCategories" @change-page="navigateTo" @update-data="updateData"
|
||||||
@update-data="updateData" @add-to-cart="addProductToCart"></customer-market>
|
@add-to-cart="addProductToCart"></customer-market>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue