mirror of
https://github.com/believethehype/nostrdvm.git
synced 2025-06-27 23:00:51 +02:00
reduce requests to check for active dvms
This commit is contained in:
parent
2a569a1fa4
commit
1e35c652e8
@ -92,7 +92,13 @@ async function zap(lud16, eventid, authorid){
|
|||||||
try {
|
try {
|
||||||
webln = await requestProvider();
|
webln = await requestProvider();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
if (invoice === null){
|
||||||
|
invoice = await createBolt11Lud16(lud16, 21)
|
||||||
|
}
|
||||||
|
|
||||||
await copyinvoice(invoice)
|
await copyinvoice(invoice)
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
if (webln) {
|
if (webln) {
|
||||||
try{
|
try{
|
||||||
|
@ -305,29 +305,52 @@ const urlinput = ref("");
|
|||||||
|
|
||||||
async function addAllContentDVMs() {
|
async function addAllContentDVMs() {
|
||||||
|
|
||||||
|
let relevent_dvms = []
|
||||||
for (const el of store.state.nip89dvms) {
|
for (const el of store.state.nip89dvms) {
|
||||||
for (const tag of JSON.parse(el.event).tags) {
|
for (const tag of JSON.parse(el.event).tags) {
|
||||||
|
|
||||||
if (tag[0] === "k" && tag[1] === "5300") {
|
if (tag[0] === "k" && tag[1] === "5300") {
|
||||||
|
relevent_dvms.push(PublicKey.parse(el.id))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let active_dvms = []
|
||||||
|
for (let id of relevent_dvms) {
|
||||||
|
let jsonentry = {
|
||||||
|
id: id.toHex(),
|
||||||
|
last_active: 0
|
||||||
|
}
|
||||||
|
active_dvms.push(jsonentry)
|
||||||
|
|
||||||
const filtera = new Filter().author(PublicKey.parse(el.id)).kinds([6300, 7000]).limit(1)
|
}
|
||||||
|
|
||||||
|
console.log(active_dvms)
|
||||||
|
|
||||||
|
const filtera = new Filter().authors(relevent_dvms).kinds([6300, 7000])
|
||||||
let client = store.state.client
|
let client = store.state.client
|
||||||
let activities = await client.getEventsOf([filtera], Duration.fromSecs(1))
|
let activities = await client.getEventsOf([filtera], Duration.fromSecs(1))
|
||||||
let last_active = 0
|
|
||||||
|
|
||||||
|
//let last_active = 0
|
||||||
|
|
||||||
for (let activity of activities) {
|
for (let activity of activities) {
|
||||||
|
|
||||||
//console.log(activity.createdAt.asSecs())
|
//console.log(activity.createdAt.asSecs())
|
||||||
if (activity.createdAt.asSecs() > last_active){
|
if (activity.createdAt.asSecs() > active_dvms.find(x => x.id === activity.author.toHex()).last_active) {
|
||||||
last_active = activity.createdAt.asSecs()
|
//last_active = activity.createdAt.asSecs()
|
||||||
|
active_dvms.find(x => x.id === activity.author.toHex()).last_active = activity.createdAt.asSecs()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// console.log(last_active)
|
// console.log(last_active)
|
||||||
// If DVM hasnt been active for 3 weeks, don't consider it.
|
// If DVM hasnt been active for 3 weeks, don't consider it.
|
||||||
if(last_active < Timestamp.now().asSecs() - 60*60*24*7){
|
console.log(active_dvms)
|
||||||
continue
|
let final_dvms = []
|
||||||
|
for (let element of active_dvms) {
|
||||||
|
if (element.last_active > Timestamp.now().asSecs() - 60 * 60 * 24 * 7) {
|
||||||
|
final_dvms.push(store.state.nip89dvms.find(x => x.id === element.id))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (let el of final_dvms){
|
||||||
|
|
||||||
let status = "announced"
|
let status = "announced"
|
||||||
let jsonentry = {
|
let jsonentry = {
|
||||||
@ -347,12 +370,13 @@ async function addAllContentDVMs(){
|
|||||||
if (dvms.filter(i => i.id === jsonentry.id).length === 0) {
|
if (dvms.filter(i => i.id === jsonentry.id).length === 0) {
|
||||||
dvms.push(jsonentry)
|
dvms.push(jsonentry)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
store.commit('set_recommendation_dvms', dvms)
|
store.commit('set_recommendation_dvms', dvms)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
async function addDVM(event){
|
async function addDVM(event){
|
||||||
@ -534,8 +558,11 @@ const submitHandler = async () => {
|
|||||||
Algorithms, but you are the one in control.</h2>
|
Algorithms, but you are the one in control.</h2>
|
||||||
<h3>
|
<h3>
|
||||||
<br>
|
<br>
|
||||||
|
<div class="align-content-center">
|
||||||
<button v-if="store.state.recommendationdvms.length === 0" class="v-Button">Loading DVMs..</button>
|
<button v-if="store.state.recommendationdvms.length === 0" class="v-Button">Loading DVMs..</button>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
</h3>
|
</h3>
|
||||||
</div>
|
</div>
|
||||||
<br>
|
<br>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user