mirror of
https://github.com/believethehype/nostrdvm.git
synced 2025-11-18 14:06:55 +01:00
noogle: more mobile optimizations
This commit is contained in:
@@ -402,7 +402,7 @@ const submitHandler = async () => {
|
||||
|
||||
<div className="card-actions justify-end mt-auto" >
|
||||
|
||||
<div className="tooltip mt-auto" :data-tip="dvm.status">
|
||||
<div className="tooltip mt-auto" >
|
||||
|
||||
|
||||
<button v-if="dvm.status === 'processing'" className="btn">Processing</button>
|
||||
|
||||
@@ -130,6 +130,8 @@ export default {
|
||||
this.supports_android_signer = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (localStorage.getItem('nostr-key-method') === 'nip07') {
|
||||
await this.sign_in_nip07()
|
||||
}
|
||||
@@ -148,11 +150,15 @@ export default {
|
||||
}
|
||||
await this.sign_in_amber(key)
|
||||
}
|
||||
|
||||
|
||||
else {
|
||||
await this.sign_in_anon()
|
||||
}
|
||||
await this.getnip89s()
|
||||
|
||||
|
||||
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
@@ -211,7 +217,7 @@ export default {
|
||||
localStorage.setItem('nostr-key', '')
|
||||
console.log("Client Nip46 connected")
|
||||
await this.get_user_info(pubkey)
|
||||
await this.reconcile_all_profiles(pubkey)
|
||||
this.reconcile_all_profiles(pubkey)
|
||||
console.log(pubkey.toBech32())
|
||||
//await this.reconcile_all_profiles()
|
||||
|
||||
@@ -327,7 +333,7 @@ export default {
|
||||
localStorage.setItem('nostr-key', keys.secretKey.toBech32())
|
||||
console.log("Client key connected")
|
||||
await this.get_user_info(pubkey)
|
||||
await this.reconcile_all_profiles(pubkey)
|
||||
this.reconcile_all_profiles(pubkey)
|
||||
|
||||
|
||||
} catch (error) {
|
||||
@@ -392,8 +398,8 @@ export default {
|
||||
localStorage.setItem('nostr-key', pubkey.toHex())
|
||||
console.log("Client Nip07 connected")
|
||||
await this.get_user_info(pubkey)
|
||||
await this.getnip89s()
|
||||
await this.reconcile_all_profiles(pubkey)
|
||||
|
||||
this.reconcile_all_profiles(pubkey)
|
||||
//await this.reconcile_all_profiles()
|
||||
//miniToastr.showMessage("Login successful!", "Logged in as " + this.current_user, VueNotifications.types.success)
|
||||
|
||||
@@ -460,11 +466,12 @@ export default {
|
||||
localStorage.setItem('nostr-key', connectionstring)
|
||||
console.log("Client connected")
|
||||
|
||||
|
||||
|
||||
|
||||
this.reconcile_all_profiles(pubkey)
|
||||
await this.get_user_info(pubkey)
|
||||
|
||||
|
||||
await this.reconcile_all_profiles(pubkey)
|
||||
|
||||
//miniToastr.showMessage("Login successful!", "Logged in as " + this.current_user, VueNotifications.types.success)
|
||||
|
||||
|
||||
@@ -520,10 +527,9 @@ export default {
|
||||
localStorage.setItem('nostr-key-method', "android-signer")
|
||||
localStorage.setItem('nostr-key', hexKey)
|
||||
|
||||
|
||||
this.reconcile_all_profiles(publicKey)
|
||||
await this.get_user_info(publicKey)
|
||||
|
||||
|
||||
await this.reconcile_all_profiles(publicKey)
|
||||
}
|
||||
catch (error){
|
||||
alert(error)
|
||||
@@ -541,11 +547,14 @@ export default {
|
||||
let keys = Keys.parse("ece3c0aa759c3e895ecb3c13ab3813c0f98430c6d4bd22160b9c2219efc9cf0e")
|
||||
let signer = NostrSigner.keys(keys) //TODO store keys
|
||||
let client = new ClientBuilder().signer(signer).build()
|
||||
|
||||
for (const relay of store.state.relays) {
|
||||
await client.addRelay(relay);
|
||||
}
|
||||
await client.connect();
|
||||
|
||||
|
||||
|
||||
let dvmkinds = []
|
||||
for (let i = 5000; i < 6000; i++) {
|
||||
dvmkinds.push((i.toString()))
|
||||
|
||||
@@ -33,16 +33,13 @@ async function generate_feed() {
|
||||
|
||||
try {
|
||||
if(store.state.pubkey === undefined || localStorage.getItem('nostr-key-method') === "anon"){
|
||||
miniToastr.showMessage("In order to receive personalized recommendations, sign-in first.", "Not signed in.", VueNotifications.types.warn)
|
||||
return
|
||||
miniToastr.showMessage("Some algorithms may need your profile to give personalized recommendations. Sign-in for a better experience.", "Not signed in.", VueNotifications.types.warn)
|
||||
|
||||
}
|
||||
|
||||
for (let dvm of dvms){
|
||||
dvm = {}
|
||||
dvms.pop()
|
||||
}
|
||||
dvms = []
|
||||
store.commit('set_recommendation_dvms', dvms)
|
||||
|
||||
let client = store.state.client
|
||||
|
||||
let content = "NIP 90 Content Discovery request"
|
||||
@@ -76,8 +73,6 @@ async function generate_feed() {
|
||||
|
||||
|
||||
requestid = res.toHex();
|
||||
console.log(requestid)
|
||||
|
||||
}
|
||||
|
||||
store.commit('set_current_request_id_recommendation', requestid)
|
||||
@@ -96,6 +91,8 @@ async function generate_feed() {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
async function listen() {
|
||||
let client = store.state.client
|
||||
let pubkey = store.state.pubkey
|
||||
@@ -113,27 +110,118 @@ async function listen() {
|
||||
console.log("Received new event from", relayUrl);
|
||||
//console.log(event.asJson())
|
||||
let resonsetorequest = false
|
||||
sleep(1500).then(async () => {
|
||||
sleep(1200).then(async () => {
|
||||
for (let tag in event.tags) {
|
||||
if (event.tags[tag].asVec()[0] === "e") {
|
||||
//console.log(event.tags[tag].asVec()[1])
|
||||
//console.log(test)
|
||||
if (event.tags[tag].asVec()[1] === store.state.requestidRecommendation) {
|
||||
resonsetorequest = true
|
||||
console.log("YES")
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (resonsetorequest === true) {
|
||||
if (event.kind === 7000) {
|
||||
|
||||
|
||||
try {
|
||||
console.log("7000: ", event.content);
|
||||
console.log("DVM: " + event.author.toHex())
|
||||
// console.log("DVM: " + event.author.toHex())
|
||||
//miniToastr.showMessage("DVM: " + dvmname, event.content, VueNotifications.types.info)
|
||||
|
||||
await addDVM(event)
|
||||
|
||||
} catch (error) {
|
||||
console.log("Error: ", error);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
else if (event.kind === 6300) {
|
||||
let entries = []
|
||||
//console.log("6300:", event.content);
|
||||
|
||||
let event_etags = JSON.parse(event.content)
|
||||
if (event_etags.length > 0) {
|
||||
for (let etag of event_etags) {
|
||||
const eventid = EventId.fromHex(etag[1]).toHex()
|
||||
entries.push(eventid)
|
||||
}
|
||||
const events = await getEventsOriginalOrder(entries)
|
||||
let authors = []
|
||||
for (const evt of events) {
|
||||
authors.push(evt.author)
|
||||
}
|
||||
|
||||
if (authors.length > 0) {
|
||||
let profiles = await get_user_infos(authors)
|
||||
let items = []
|
||||
let index = 0
|
||||
for (const evt of events) {
|
||||
let p = profiles.find(record => record.author === evt.author.toHex())
|
||||
let bech32id = evt.id.toBech32()
|
||||
let nip19 = new Nip19Event(evt.id, evt.author, store.state.relays)
|
||||
let nip19bech32 = nip19.toBech32()
|
||||
let picture = p === undefined ? "../assets/nostr-purple.svg" : p["profile"]["picture"]
|
||||
let name = p === undefined ? bech32id : p["profile"]["name"]
|
||||
let highlighterurl = "https://highlighter.com/e/" + nip19bech32
|
||||
let njumpurl = "https://njump.me/" + nip19bech32
|
||||
let nostrudelurl = "https://nostrudel.ninja/#/n/" + bech32id
|
||||
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,
|
||||
index: index,
|
||||
indicator: {"time": evt.createdAt.toHumanDatetime(), "index": index}
|
||||
})
|
||||
index = index+1
|
||||
}
|
||||
|
||||
}
|
||||
if (dvms.find(i => i.id === event.author.toHex()) === undefined){
|
||||
await addDVM(event)
|
||||
console.log("add dvm because of bug")
|
||||
}
|
||||
|
||||
|
||||
dvms.find(i => i.id === event.author.toHex()).result.length = 0
|
||||
dvms.find(i => i.id === event.author.toHex()).result.push.apply(dvms.find(i => i.id === event.author.toHex()).result, items)
|
||||
dvms.find(i => i.id === event.author.toHex()).status = "finished"
|
||||
|
||||
}
|
||||
}
|
||||
store.commit('set_recommendation_dvms', dvms)
|
||||
}
|
||||
|
||||
}
|
||||
})
|
||||
},
|
||||
// Handle relay message
|
||||
handleMsg: async (relayUrl, message) => {
|
||||
//console.log("Received message from", relayUrl, message.asJson());
|
||||
}
|
||||
};
|
||||
|
||||
client.handleNotifications(handle);
|
||||
}
|
||||
|
||||
|
||||
const urlinput = ref("");
|
||||
|
||||
async function addDVM(event){
|
||||
let status = "unknown"
|
||||
let jsonentry = {
|
||||
id: event.author.toHex(),
|
||||
@@ -204,104 +292,22 @@ async function listen() {
|
||||
|
||||
}
|
||||
}
|
||||
if (dvms.filter(i => i.id === jsonentry.id).length === 0) {
|
||||
|
||||
dvms.push(jsonentry)
|
||||
}
|
||||
if (event.content !== ""){
|
||||
|
||||
if (event.content !== "" && status !== "payment-required" && status !== "error" && status !== "finished" && status !== "paid"){
|
||||
status = event.content
|
||||
}
|
||||
jsonentry.status = status
|
||||
console.log(dvms)
|
||||
if (dvms.filter(i => i.id === jsonentry.id).length === 0) {
|
||||
dvms.push(jsonentry)
|
||||
}
|
||||
|
||||
dvms.find(i => i.id === jsonentry.id).status = status
|
||||
|
||||
//dvms.find(i => i.id === jsonentry.id).status = status
|
||||
store.commit('set_recommendation_dvms', dvms)
|
||||
|
||||
|
||||
} catch (error) {
|
||||
console.log("Error: ", error);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
else if (event.kind === 6300) {
|
||||
let entries = []
|
||||
console.log("6300:", event.content);
|
||||
|
||||
let event_etags = JSON.parse(event.content)
|
||||
if (event_etags.length > 0) {
|
||||
for (let etag of event_etags) {
|
||||
const eventid = EventId.fromHex(etag[1]).toHex()
|
||||
entries.push(eventid)
|
||||
}
|
||||
const events = await getEventsOriginalOrder(entries)
|
||||
let authors = []
|
||||
for (const evt of events) {
|
||||
authors.push(evt.author)
|
||||
}
|
||||
|
||||
if (authors.length > 0) {
|
||||
let profiles = await get_user_infos(authors)
|
||||
let items = []
|
||||
let index = 0
|
||||
for (const evt of events) {
|
||||
let p = profiles.find(record => record.author === evt.author.toHex())
|
||||
let bech32id = evt.id.toBech32()
|
||||
let nip19 = new Nip19Event(evt.id, evt.author, store.state.relays)
|
||||
let nip19bech32 = nip19.toBech32()
|
||||
let picture = p === undefined ? "../assets/nostr-purple.svg" : p["profile"]["picture"]
|
||||
let name = p === undefined ? bech32id : p["profile"]["name"]
|
||||
let highlighterurl = "https://highlighter.com/e/" + nip19bech32
|
||||
let njumpurl = "https://njump.me/" + nip19bech32
|
||||
let nostrudelurl = "https://nostrudel.ninja/#/n/" + bech32id
|
||||
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,
|
||||
index: index,
|
||||
indicator: {"time": evt.createdAt.toHumanDatetime(), "index": index}
|
||||
})
|
||||
index = index+1
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
dvms.find(i => i.id === event.author.toHex()).result.length = 0
|
||||
dvms.find(i => i.id === event.author.toHex()).result.push.apply(dvms.find(i => i.id === event.author.toHex()).result, items)
|
||||
dvms.find(i => i.id === event.author.toHex()).status = "finished"
|
||||
}
|
||||
}
|
||||
store.commit('set_recommendation_dvms', dvms)
|
||||
}
|
||||
|
||||
}
|
||||
})
|
||||
},
|
||||
// Handle relay message
|
||||
handleMsg: async (relayUrl, message) => {
|
||||
//console.log("Received message from", relayUrl, message.asJson());
|
||||
}
|
||||
};
|
||||
|
||||
client.handleNotifications(handle);
|
||||
}
|
||||
|
||||
|
||||
const urlinput = ref("");
|
||||
|
||||
|
||||
async function zap(invoice) {
|
||||
let webln;
|
||||
|
||||
@@ -449,6 +455,7 @@ const submitHandler = async () => {
|
||||
<button v-if="dvm.status === 'finished'" className="btn">Done</button>
|
||||
<button v-if="dvm.status === 'paid'" className="btn">Paid, waiting for DVM..</button>
|
||||
<button v-if="dvm.status === 'error'" className="btn">Error</button>
|
||||
|
||||
<button v-if="dvm.status === 'payment-required'" className="zap-Button" @click="zap(dvm.bolt11);">{{ dvm.amount/1000 }} Sats</button>
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user