diff --git a/ui/noogle/src/components/ImageGeneration.vue b/ui/noogle/src/components/ImageGeneration.vue index 55c264d..980e839 100644 --- a/ui/noogle/src/components/ImageGeneration.vue +++ b/ui/noogle/src/components/ImageGeneration.vue @@ -214,13 +214,15 @@ async function listen() { } //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()) { jsonentry.name = el.name jsonentry.about = el.about jsonentry.image = el.image jsonentry.nip90Params = el.nip90Params - jsonentry.reactions = await dvmreactions(PublicKey.parse(el.id)) + jsonentry.reactions = await dvmreactions(PublicKey.parse(el.id), store.state.followings) jsonentry.reactions.negativeUser = false jsonentry.reactions.positiveUser = false jsonentry.event = Event.fromJson(el.event) diff --git a/ui/noogle/src/components/Login.vue b/ui/noogle/src/components/Login.vue index 422c018..3a566b5 100644 --- a/ui/noogle/src/components/Login.vue +++ b/ui/noogle/src/components/Login.vue @@ -871,6 +871,7 @@ export default { let followings = [] + let ids = [] let followers_filter = new Filter().author(publicKey).kind(3).limit(1) let followers = await dbclient.getEventsOf([followers_filter], Duration.fromSecs(5)) console.log(followers) @@ -879,6 +880,7 @@ export default { if (tag.asVec()[0] === "p") { let following = tag.asVec()[1] followings.push(PublicKey.parse(following)) + ids.push((following)) } } @@ -889,6 +891,8 @@ export default { let filter = new Filter().kind(0).authors(followings) + store.commit('set_followings', ids) + await dbclient.reconcile(filter, opts); console.log("Done syncing profiles") diff --git a/ui/noogle/src/components/helper/Helper.vue b/ui/noogle/src/components/helper/Helper.vue index 01ead3c..0d7a67b 100644 --- a/ui/noogle/src/components/helper/Helper.vue +++ b/ui/noogle/src/components/helper/Helper.vue @@ -381,7 +381,7 @@ export async function fetchAsync (url) { return data; } -export async function dvmreactions(dvmid) { +export async function dvmreactions(dvmid, authors) { let reactions = { positive: [], negative: [], @@ -391,27 +391,21 @@ export async function dvmreactions(dvmid) { let client = store.state.client - if (store.state.dbclient.database === undefined){ - console.log("not logged in, not getting profile suggestions") - return [] - } - let dbclient = store.state.dbclient - let profiles = [] - let filter1 = new Filter().kind(0) - let users = await dbclient.database.query([filter1]) - - console.log(users) - - let authors = [] - for (const entry of users){ - authors.push(entry.author) - } + let authorscheck = [] + for (let author of authors){ + try{ + authorscheck.push(PublicKey.parse(author)) + } + catch{ + console.log("err" + author) + } + } - let reactionfilter = new Filter().kind(7).pubkey (dvmid).authors(authors).since(Timestamp.fromSecs(Timestamp.now().asSecs() - 60*60*24*60)) // reactions by our followers in the last 2 months + + let reactionfilter = new Filter().kind(7).pubkey (dvmid).authors(authorscheck).since(Timestamp.fromSecs(Timestamp.now().asSecs() - 60*60*24*60)) // reactions by our followers in the last 2 months let evts = await client.getEventsOf([reactionfilter], Duration.fromSecs(5)) - console.log(evts) if (evts.length > 0){ for (let reaction of evts){ if (reaction.content === "👎"){ diff --git a/ui/noogle/src/store.js b/ui/noogle/src/store.js index ee50d7c..04478d8 100644 --- a/ui/noogle/src/store.js +++ b/ui/noogle/src/store.js @@ -9,6 +9,7 @@ const store = createStore({ signer: NostrSigner, dbclient: Client, pubkey: PublicKey, + followings: [], nooglekey: import.meta.env.VITE_NOOGLE_PK, subscription_verifier_pubkey: import.meta.env.VITE_SUBSCRIPTIPON_VERIFIER_PUBKEY, requestidSearch: String, @@ -51,6 +52,10 @@ const store = createStore({ set_pubkey(state, pubkey) { state.pubkey = pubkey }, + set_followings(state, items) { + state.followings.length = 0 + state.followings.push.apply(state.followings, items) + }, set_hasEventListener(state, hasEventListener) { state.hasEventListener = hasEventListener },