diff --git a/templates/nostrmarket/market.html b/templates/nostrmarket/market.html
index 103d7db..a85f2fc 100644
--- a/templates/nostrmarket/market.html
+++ b/templates/nostrmarket/market.html
@@ -24,20 +24,31 @@
>
-
+
+ {%raw%}
-
+
+
- {%raw%}
{{ `${pub.slice(0, 5)}...${pub.slice(-5)}` }}{{ pub }}{{ profiles.get(pub).name }}
+ {{ `${pub.slice(0, 5)}...${pub.slice(-5)}`
+ }}
+ {{ pub }}
{% raw %}
{
this.events = events || []
this.events.map(eventToObj).map(e => {
- if (e.content.stall) {
- //it's a product
- this.products.push(e.content)
+ if (e.kind == 0) {
+ this.profiles.set(e.pubkey, e.content)
+ return
+ } else if (e.content.stall) {
+ //it's a product `d` is the prod. id
+ products.set(e.d, e.content)
} else {
- // it's a stall
- this.stalls.push(e.content)
+ // it's a stall `d` is the stall id
+ stalls.set(e.d, e.content)
return
}
})
})
await Promise.resolve(sub)
- this.pool.close()
+ this.products = Array.from(products.values())
+ this.stalls = Array.from(stalls.values())
+ pool.close(relays)
},
async getRates() {
let noFiat = this.stalls.map(s => s.currency).every(c => c == 'sat')
@@ -329,32 +352,36 @@
getAmountFormated(amount, unit = 'USD') {
return LNbits.utils.formatCurrency(amount, unit)
},
- addPubkey() {
+ async addPubkey() {
let pubkey = String(this.inputPubkey).trim()
let regExp = /^#([0-9a-f]{3}){1,2}$/i
- if (regExp.test(pubkey)) {
- return this.pubkeys.add(pubkey)
- }
- try {
- let {type, data} = nostr.nip19.decode(pubkey)
- if (type === 'npub') pubkey = data
- else if (type === 'nprofile') {
- pubkey = data.pubkey
- givenRelays = data.relays
+ if (pubkey.startsWith('n')) {
+ try {
+ let {type, data} = nostr.nip19.decode(pubkey)
+ if (type === 'npub') pubkey = data
+ else if (type === 'nprofile') {
+ pubkey = data.pubkey
+ givenRelays = data.relays
+ }
+ this.pubkeys.add(pubkey)
+ this.inputPubkey = null
+ } catch (err) {
+ console.error(err)
}
- this.pubkeys.add(pubkey)
- this.inputPubkey = null
- } catch (err) {
- console.error(err)
+ } else if (regExp.test(pubkey)) {
+ pubkey = pubkey
}
+ this.pubkeys.add(pubkey)
+ await this.initNostr()
},
removePubkey(pubkey) {
// Needs a hack for Vue reactivity
let pubkeys = this.pubkeys
pubkeys.delete(pubkey)
+ this.profiles.delete(pubkey)
this.pubkeys = new Set(Array.from(pubkeys))
},
- addRelay() {
+ async addRelay() {
let relay = String(this.inputRelay).trim()
if (!relay.startsWith('ws')) {
console.debug('invalid url')
@@ -362,6 +389,7 @@
}
this.relays.add(relay)
this.inputRelay = null
+ await this.initNostr()
},
removeRelay(relay) {
// Needs a hack for Vue reactivity