diff --git a/ui/noogle/src/components/Nip89view.vue b/ui/noogle/src/components/Nip89view.vue index 87bf90b..0436829 100644 --- a/ui/noogle/src/components/Nip89view.vue +++ b/ui/noogle/src/components/Nip89view.vue @@ -8,7 +8,9 @@

Free

-

{{ dvm.amount/1000 }}

+

Flexible

+ +

Subscription

{{dvm.amount/1000}}

diff --git a/ui/noogle/src/components/NoteTable.vue b/ui/noogle/src/components/NoteTable.vue index 2d290ea..3f6076e 100644 --- a/ui/noogle/src/components/NoteTable.vue +++ b/ui/noogle/src/components/NoteTable.vue @@ -170,7 +170,7 @@ async function zap(lud16, eventid, authorid){ let objects = (props.data.find(x=> x.id === eventid)) if (objects !== undefined){ - console.log(objects.zapped) + // console.log(objects.zapped) objects.zapped = true objects.zapAmount += 21000 } diff --git a/ui/noogle/src/components/RecommendationGeneration.vue b/ui/noogle/src/components/RecommendationGeneration.vue index 29c6ff0..d2e31bb 100644 --- a/ui/noogle/src/components/RecommendationGeneration.vue +++ b/ui/noogle/src/components/RecommendationGeneration.vue @@ -22,7 +22,7 @@ import {data} from "autoprefixer"; import {requestProvider} from "webln"; import Newnote from "@/components/Newnote.vue"; import SummarizationGeneration from "@/components/SummarizationGeneration.vue" -import {post_note, schedule, copyurl, copyinvoice, sleep, getEvents, get_user_infos, get_zaps, get_reactions, nextInput, createBolt11Lud16, getEventsOriginalOrder, parseandreplacenpubsName} from "../components/helper/Helper.vue" +import {post_note, schedule, copyurl, copyinvoice, sleep, getEvents, get_user_infos, get_zaps, zaprequest, get_reactions, nextInput, createBolt11Lud16, getEventsOriginalOrder, parseandreplacenpubsName} from "../components/helper/Helper.vue" import amberSignerService from "./android-signer/AndroidSigner"; import StringUtil from "@/components/helper/string.ts"; @@ -36,7 +36,6 @@ onMounted(async () => { await sleep(100) } await addAllContentDVMs() -console.log("mount") console.log(dvms) }) @@ -45,10 +44,7 @@ console.log("mount") async function generate_feed(id) { try { - if(store.state.pubkey === undefined || localStorage.getItem('nostr-key-method') === "anon"){ - miniToastr.showMessage("Some algorithms may need your profile to give personalized recommendations. Sign-in for a better experience.", "Not signed in.", VueNotifications.types.warn) - } //dvms = [] //store.commit('set_recommendation_dvms', dvms) @@ -121,7 +117,7 @@ async function listen() { return true }*/ //const dvmname = getNamefromId(event.author.toHex()) - console.log("Received new event from", relayUrl); + //console.log("Received new event from", relayUrl); //console.log(event.asJson()) let resonsetorequest = false sleep(1200).then(async () => { @@ -142,6 +138,7 @@ async function listen() { console.log("7000: ", event.content); // console.log("DVM: " + event.author.toHex()) //miniToastr.showMessage("DVM: " + dvmname, event.content, VueNotifications.types.info) + dvms.find(i => i.id === event.author.toHex()).laststatusid = event.id.toHex() for (const tag in event.tags) { if (event.tags[tag].asVec()[0] === "status") { @@ -162,7 +159,11 @@ async function listen() { } } - + if (event.tags[tag].asVec()[0] === "subscribed") { + if (Timestamp.fromSecs(parseInt(event.tags[tag].asVec()[1])).asSecs() > Timestamp.now().asSecs()) { + dvms.find(i => i.id === event.author.toHex()).subscription = event.tags[tag].asVec()[1] + } + } if (event.tags[tag].asVec()[0] === "amount") { dvms.find(i => i.id === event.author.toHex()).amount = event.tags[tag].asVec()[1] @@ -184,10 +185,12 @@ async function listen() { let lud16 = current.profile.lud16 if (lud16 !== null && lud16 !== "") { console.log("LUD16: " + lud16) - dvms.find(i => i.id === event.author.toHex()).bolt11 = await createBolt11Lud16(lud16, dvms.find(i => i.id === event.author.toHex()).amount) + dvms.find(i => i.id === event.author.toHex()).bolt11 = await zaprequest(lud16, dvms.find(i => i.id === event.author.toHex()).amount, "paid from noogle.lol", event.id.toHex(), event.author.toHex(), store.state.relays) + //dvms.find(i => i.id === event.author.toHex()).bolt11 = await createBolt11Lud16(lud16, dvms.find(i => i.id === event.author.toHex()).amount) console.log(dvms.find(i => i.id === event.author.toHex()).bolt11) if (dvms.find(i => i.id === event.author.toHex()).bolt11 === "") { dvms.find(i => i.id === event.author.toHex()).status = "error" + } } else { console.log("NO LNURL") @@ -378,16 +381,19 @@ async function addAllContentDVMs() { id: el.id, kind: "", status: status, + laststatusid: "", result: [], name: el.name, about: el.about, image: el.image, amount: el.amount, - bolt11: "" + bolt11: "", + lud16: el.lud16, + subscription: "" } - console.log(jsonentry) + //console.log(jsonentry) if (dvms.filter(i => i.id === jsonentry.id).length === 0) { dvms.push(jsonentry) } @@ -411,7 +417,9 @@ async function addDVM(event){ about: "", image: "", amount: 0, - bolt11: "" + bolt11: "", + lud16: "", + subscription: "" } for (const tag in event.tags) { @@ -457,15 +465,21 @@ async function addDVM(event){ } } } + + + + + } //let dvm = store.state.nip89dvms.find(x => JSON.parse(x.event).pubkey === event.author.toHex()) for (const el of store.state.nip89dvms) { - if (JSON.parse(el.event).pubkey === event.author.toHex().toString()) { + if (JSON.parse(el.event).pubkey === event.author.toHex()) { jsonentry.name = el.name jsonentry.about = el.about jsonentry.image = el.image + jsonentry.lud16 = el.lud16 console.log(jsonentry) @@ -489,7 +503,19 @@ async function addDVM(event){ } +async function subscribe(lud16, days, amountperday, eventid, authorid) { + if (lud16 !== "") { + let profiles = await get_user_infos([PublicKey.parse(authorid)]) + if (profiles.length > 0) { + let current = profiles[0] + lud16 = current.profile.lud16 + } + } + let invoice = await zaprequest(lud16, days * amountperday, "paid from noogle.lol", eventid, authorid, store.state.relays) + console.log(invoice) + await zap(invoice) +} async function zap(invoice) { let webln; @@ -640,12 +666,36 @@ const submitHandler = async () => {
- + + +
+ +
+
+

Subscribe

+
+
+
+

Subscribe for a day

+ + + +

Subscribe for a month

+ + +
+
+
+ +
+ + + @@ -671,11 +721,30 @@ const submitHandler = async () => { -
-

Free

-

{{ dvm.amount/1000 }}

+
+

Free

+

Flexible

+

Subscription

+
+
+

Subscription active until + {{Timestamp.fromSecs(parseInt(dvm.subscription)).toHumanDatetime().split("T")[0].split("-")[2].trim()}}.{{Timestamp.fromSecs(parseInt(dvm.subscription)).toHumanDatetime().split("T")[0].split("-")[1].trim()}}.{{Timestamp.fromSecs(parseInt(dvm.subscription)).toHumanDatetime().split("T")[0].split("-")[0].trim().slice(2)}} {{Timestamp.fromSecs(parseInt(dvm.subscription)).toHumanDatetime().split("T")[1].split("Z")[0].trim()}}

+
+ +

-

+ +

{{dvm.amount/1000}}

@@ -716,6 +785,11 @@ const submitHandler = async () => { bottom: 0; } +.sub-Button{ + @apply btn hover:bg-nostr border-orange-500 text-base; + bottom: 0; +} + .request-Button{ @apply btn hover:bg-nostr border-nostr text-base; bottom: 0; diff --git a/ui/noogle/src/components/helper/Helper.vue b/ui/noogle/src/components/helper/Helper.vue index 24aabec..ee38f00 100644 --- a/ui/noogle/src/components/helper/Helper.vue +++ b/ui/noogle/src/components/helper/Helper.vue @@ -169,7 +169,7 @@ export async function get_zaps(ids){ } if (tg[0] === "e") { etag = tg[1] - console.log(request.pubkey) + //console.log(request.pubkey) if (request.pubkey === localStorage.getItem("nostr-key")) { zapsandreactions.find(x => x.id === etag).zappedbyUser = true } @@ -184,7 +184,6 @@ export async function get_zaps(ids){ for (let tag of entry.tags) { if (tag.asVec()[0] === "e") { - console.log(entry.pubkey) if (entry.author.toHex() === localStorage.getItem("nostr-key")) { zapsandreactions.find(x => x.id === tag.asVec()[1]).reactedbyUser = true } @@ -201,12 +200,12 @@ export async function get_zaps(ids){ //zaps.push({profile: contentjson, author: entry.author.toHex(), createdAt: entry.createdAt}); } catch(error){ - console.log("error") + //console.log(error) } } - console.log(zapsandreactions) + //console.log(zapsandreactions) return zapsandreactions