mirror of
https://github.com/believethehype/nostrdvm.git
synced 2025-10-10 01:22:57 +02:00
fixes
This commit is contained in:
@@ -32,7 +32,9 @@ let listener = false
|
||||
|
||||
|
||||
|
||||
|
||||
const sleep = (ms) => {
|
||||
return new Promise(resolve => setTimeout(resolve, ms))
|
||||
}
|
||||
async function generate_image(message) {
|
||||
|
||||
try {
|
||||
@@ -90,6 +92,7 @@ async function listen() {
|
||||
//const dvmname = getNamefromId(event.author.toHex())
|
||||
console.log("Received new event from", relayUrl);
|
||||
let resonsetorequest = false
|
||||
sleep(500).then(async () => {
|
||||
for (let tag in event.tags) {
|
||||
if (event.tags[tag].asVec()[0] === "e") {
|
||||
console.log("IMAGE ETAG: " + event.tags[tag].asVec()[1])
|
||||
@@ -103,11 +106,9 @@ async function listen() {
|
||||
if (resonsetorequest === true) {
|
||||
|
||||
|
||||
|
||||
if (event.kind === 7000) {
|
||||
|
||||
|
||||
|
||||
try {
|
||||
console.log("7000: ", event.content);
|
||||
console.log("DVM: " + event.author.toHex())
|
||||
@@ -167,10 +168,7 @@ async function listen() {
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
else if(event.kind === 6100) {
|
||||
} else if (event.kind === 6100) {
|
||||
let entries = []
|
||||
console.log("6100:", event.content);
|
||||
|
||||
@@ -180,6 +178,7 @@ async function listen() {
|
||||
store.commit('set_imagedvm_results', dvms)
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
// Handle relay message
|
||||
handleMsg: async (relayUrl, message) => {
|
||||
|
@@ -132,8 +132,8 @@ export default {
|
||||
this.signer = ClientSigner.keys(Keys.generate())
|
||||
}
|
||||
|
||||
let zapper = ClientZapper.webln()
|
||||
let client = new ClientBuilder().signer(this.signer).zapper(zapper).build();
|
||||
//let zapper = ClientZapper.webln()
|
||||
let client = new ClientBuilder().signer(this.signer).build();
|
||||
|
||||
for (const relay of store.state.relays){
|
||||
await client.addRelay(relay);
|
||||
|
@@ -9,7 +9,7 @@ import {
|
||||
EventBuilder,
|
||||
Tag,
|
||||
EventId,
|
||||
Nip19Event
|
||||
Nip19Event, Alphabet
|
||||
} from "@rust-nostr/nostr-sdk";
|
||||
import store from '../store';
|
||||
import miniToastr from "mini-toastr";
|
||||
@@ -73,7 +73,9 @@ async function send_search_request(message) {
|
||||
let evt = new EventBuilder(5302, "NIP 90 Search request", tags)
|
||||
let res = await client.sendEventBuilder(evt)
|
||||
let requestid = res.toHex()
|
||||
console.log("STORE: " +store.state.requestidSearch)
|
||||
store.commit('set_current_request_id_search', requestid)
|
||||
console.log("STORE AFTER: " + store.state.requestidSearch)
|
||||
|
||||
|
||||
//miniToastr.showMessage("Sent Request to DVMs", "Awaiting results", VueNotifications.types.warn)
|
||||
@@ -127,6 +129,7 @@ async function listen() {
|
||||
listener = true
|
||||
let client = store.state.client
|
||||
let pubkey = store.state.pubkey
|
||||
let originale = [store.state.requestidSearch]
|
||||
|
||||
const filter = new Filter().kinds([7000, 6302]).pubkey(pubkey).since(Timestamp.now());
|
||||
await client.subscribe([filter]);
|
||||
@@ -137,19 +140,23 @@ async function listen() {
|
||||
if (store.state.hasEventListener === false){
|
||||
return true
|
||||
}
|
||||
const dvmname = getNamefromId(event.author.toHex())
|
||||
//const dvmname = getNamefromId(event.author.toHex())
|
||||
console.log("Received new event from", relayUrl);
|
||||
let resonsetorequest = false
|
||||
|
||||
sleep(500).then(async () => {
|
||||
|
||||
for (let tag in event.tags) {
|
||||
if (event.tags[tag].asVec()[0] === "e") {
|
||||
console.log("SEARCH ETAG: " + event.tags[tag].asVec()[1])
|
||||
console.log("SEARCH LISTEN TO : " + store.state.requestidSearch)
|
||||
//if (event.tags[tag].asVec()[1] === store.state.requestidSearch) {
|
||||
if (event.tags[tag].asVec()[1] === store.state.requestidSearch) {
|
||||
resonsetorequest = true
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (resonsetorequest) {
|
||||
|
||||
if (event.kind === 7000) {
|
||||
@@ -195,7 +202,6 @@ async function listen() {
|
||||
jsonentry.name = el.name
|
||||
jsonentry.about = event.content
|
||||
jsonentry.image = el.image
|
||||
|
||||
console.log(jsonentry)
|
||||
|
||||
}
|
||||
@@ -204,7 +210,6 @@ async function listen() {
|
||||
dvms.push(jsonentry)
|
||||
}
|
||||
|
||||
|
||||
dvms.find(i => i.id === jsonentry.id).status = status
|
||||
if (status === "error") {
|
||||
const index = dvms.indexOf((dvms.find(i => i.id === event.author.toHex())));
|
||||
@@ -214,38 +219,20 @@ async function listen() {
|
||||
}
|
||||
|
||||
store.commit('set_active_search_dvms', dvms)
|
||||
|
||||
console.log(store.state.activesearchdvms)
|
||||
|
||||
} catch (error) {
|
||||
console.log("Error: ", error);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* try {
|
||||
console.log("7000: ", event.content);
|
||||
console.log("DVM: " + event.author.toHex())
|
||||
|
||||
|
||||
miniToastr.showMessage("DVM: " + dvmname, event.content, VueNotifications.types.info)
|
||||
} catch (error) {
|
||||
console.log("Error: ", error);
|
||||
} */
|
||||
|
||||
else if (event.kind === 6302) {
|
||||
let entries = []
|
||||
console.log("6302:", event.content);
|
||||
|
||||
//miniToastr.showMessage("DVM: " + dvmname, "Received Results", VueNotifications.types.success)
|
||||
let event_etags = JSON.parse(event.content)
|
||||
if (event_etags.length > 0) {
|
||||
for (let etag of event_etags) {
|
||||
const eventid = EventId.fromHex(etag[1])
|
||||
entries.push(eventid)
|
||||
@@ -255,9 +242,8 @@ async function listen() {
|
||||
for (const evt of events) {
|
||||
authors.push(evt.author)
|
||||
}
|
||||
if (authors.length > 0) {
|
||||
let profiles = await get_user_infos(authors)
|
||||
|
||||
|
||||
for (const evt of events) {
|
||||
let p = profiles.find(record => record.author === evt.author.toHex())
|
||||
let bech32id = evt.id.toBech32()
|
||||
@@ -271,11 +257,27 @@ async function listen() {
|
||||
let uri = "nostr:" + bech32id // nip19.toNostrUri()
|
||||
|
||||
if (items.find(e => e.id.toHex() === evt.id.toHex()) === undefined) {
|
||||
items.push({id:evt.id, content: evt.content, author: name, authorurl: "https://njump.me/" + evt.author.toBech32(), links: {"uri": uri, "highlighter": highlighterurl, "njump": njumpurl, "nostrudel": nostrudelurl} , avatar: picture, indicator: {"time": evt.createdAt.toHumanDatetime()}})
|
||||
items.push({
|
||||
id: evt.id,
|
||||
content: evt.content,
|
||||
author: name,
|
||||
authorurl: "https://njump.me/" + evt.author.toBech32(),
|
||||
links: {
|
||||
"uri": uri,
|
||||
"highlighter": highlighterurl,
|
||||
"njump": njumpurl,
|
||||
"nostrudel": nostrudelurl
|
||||
},
|
||||
avatar: picture,
|
||||
indicator: {"time": evt.createdAt.toHumanDatetime()}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const index = dvms.indexOf((dvms.find(i => i.id === event.author.toHex())));
|
||||
if (index > -1) {
|
||||
@@ -284,10 +286,10 @@ async function listen() {
|
||||
|
||||
store.commit('set_active_search_dvms', dvms)
|
||||
console.log("Events from" + event.author.toHex())
|
||||
console.log(items)
|
||||
store.commit('set_search_results', items)
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
// Handle relay message
|
||||
handleMsg: async (relayUrl, message) => {
|
||||
@@ -326,7 +328,6 @@ defineProps({
|
||||
|
||||
|
||||
<template>
|
||||
|
||||
<div class="greetings">
|
||||
<img alt="Nostr logo" class="logo" src="../assets/nostr-purple.svg" />
|
||||
<br>
|
||||
@@ -340,7 +341,6 @@ defineProps({
|
||||
</h3>
|
||||
</div>
|
||||
<div class="max-w-5xl relative space-y-3">
|
||||
|
||||
<div class="grid grid-cols-1 gap-6">
|
||||
<div className="card w-30 h-60 bg-base-100 shadow-xl" v-for="dvm in store.state.activesearchdvms"
|
||||
:key="dvm.name">
|
||||
@@ -349,23 +349,17 @@ defineProps({
|
||||
|
||||
<div className="col-end-1">
|
||||
<h2 className="card-title">{{ dvm.name }}</h2>
|
||||
|
||||
<figure v-if="dvm.image!=''" className="w-40"><img className="h-30" :src="dvm.image" alt="DVM Picture" /></figure>
|
||||
<figure v-if="dvm.image!==''" className="w-40"><img className="h-30" :src="dvm.image" alt="DVM Picture" /></figure>
|
||||
</div>
|
||||
|
||||
<div className="col-end-2 w-auto">
|
||||
<p>{{ dvm.about }}</p>
|
||||
|
||||
<div><br>
|
||||
<span className="loading loading-dots loading-lg" ></span>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -16,7 +16,13 @@ const store = createStore({
|
||||
nip89dvms: [],
|
||||
activesearchdvms: [],
|
||||
results: [],
|
||||
relays: ["wss://relay.damus.io", "wss://nos.lol", "wss://pablof7z.nostr1.com", "wss://relay.nostr.net", "wss://relay.nostr.net", "wss://relay.nostr.band", "wss://nostr-pub.wellorder.net"],
|
||||
relays: [
|
||||
//"wss://relay.damus.io",
|
||||
"wss://nos.lol",
|
||||
"wss://pablof7z.nostr1.com",
|
||||
"wss://relay.nostr.net",
|
||||
"wss://relay.nostr.band",
|
||||
"wss://nostr-pub.wellorder.net"],
|
||||
}
|
||||
},
|
||||
mutations: {
|
||||
|
Reference in New Issue
Block a user