From 8eb0d4c1fde8805cc49e7d574af00ad0b2380239 Mon Sep 17 00:00:00 2001 From: Believethehype <1097224+believethehype@users.noreply.github.com> Date: Mon, 29 Apr 2024 21:22:36 +0200 Subject: [PATCH] add amber decrypt mutes --- ui/noogle/package.json | 2 +- ui/noogle/src/components/FilterGeneration.vue | 20 ++++++++--- ui/noogle/src/components/Login.vue | 35 ++++++++++++------- 3 files changed, 38 insertions(+), 19 deletions(-) diff --git a/ui/noogle/package.json b/ui/noogle/package.json index e43a60d..6fec6f8 100644 --- a/ui/noogle/package.json +++ b/ui/noogle/package.json @@ -19,7 +19,7 @@ "bootstrap": "^5.3.2", "daisyui": "^4.6.0", "mini-toastr": "^0.8.1", - "nostr-login": "^1.1.1", + "nostr-login": "^1.3.0", "nostr-tools": "^2.4.0", "vue": "^3.4.15", "vue-notifications": "^1.0.2", diff --git a/ui/noogle/src/components/FilterGeneration.vue b/ui/noogle/src/components/FilterGeneration.vue index 937ee60..2f4f6bc 100644 --- a/ui/noogle/src/components/FilterGeneration.vue +++ b/ui/noogle/src/components/FilterGeneration.vue @@ -925,6 +925,7 @@ async function mute_all(results){ let newcontent = JSON.stringify(jsonObject) console.log(newcontent) + let lol = "[]" eventasjson.content = await (await signer).nip04Encrypt(store.state.pubkey, newcontent) let newList = new EventBuilder(list.kind, eventasjson.content, list.tags).toUnsignedEvent(store.state.pubkey) @@ -959,12 +960,21 @@ async function mute(result) { console.log(mutes.length) if (mutes.length > 0) { let list = mutes[0] - let id = list.id.toHex() + let content = "" try { let eventasjson = JSON.parse(list.asJson()) - let content = await (await signer).nip04Decrypt(store.state.pubkey, list.content) - let jsonObject = JSON.parse(content) - console.log(content) + try{ + console.log(list.content) + let signer = await store.state.signer + content = await signer.nip04Decrypt(store.state.pubkey, list.content) + console.log(content) + + } + catch(error){ + console.log(error) + } + + let jsonObject = JSON.parse(content) let exists = false for(let i = 0; i < jsonObject.length; i++) { @@ -982,7 +992,7 @@ async function mute(result) { store.state.mutes.push(result.authorid) let newcontent = JSON.stringify(jsonObject) console.log(newcontent) - eventasjson.content = await (await signer).nip04Encrypt(store.state.pubkey, newcontent) + eventasjson.content = await store.state.signer.nip04Encrypt(store.state.pubkey, newcontent) let newList = new EventBuilder(list.kind, eventasjson.content, list.tags).toUnsignedEvent(store.state.pubkey) try{ diff --git a/ui/noogle/src/components/Login.vue b/ui/noogle/src/components/Login.vue index 42508fb..e572ef4 100644 --- a/ui/noogle/src/components/Login.vue +++ b/ui/noogle/src/components/Login.vue @@ -189,7 +189,7 @@ import { Options, Duration, PublicKey, - Nip46Signer, NegentropyDirection, NegentropyOptions, NostrSigner, RelayLimits, Contact + Nip46Signer, NegentropyDirection, NegentropyOptions, NostrSigner, RelayLimits, Contact, Event } from "@rust-nostr/nostr-sdk"; import VueNotifications from "vue-notifications"; import store from '../store'; @@ -330,9 +330,9 @@ export default { } if (e.detail.type === "logout") { - await this.sign_out() + /*await this.sign_out() //await this.state.client.shutdown()G; - await this.sign_in_anon() + await this.sign_in_anon() */ console.log("Logged out") } }, @@ -940,22 +940,31 @@ export default { for (let list of mutes){ - let client = store.state.client - let signer = client.signer() - for (let tag of list.tags){ - if (tag.asVec()[0] === "p"){ - //console.log(tag.asVec()[1]) - mutelist.push(tag.asVec()[1]) + for (let tag of list.tags){ + if (tag.asVec()[0] === "p"){ + //console.log(tag.asVec()[1]) + mutelist.push(tag.asVec()[1]) + + } - } - } console.log("Public mutes: " + mutelist.length) //private mutes try { - let content = await (await signer).nip04Decrypt(store.state.pubkey, list.content) + let content = "" + console.log(store.state.pubkey.toHex()) + console.log(list.content) + if (localStorage.getItem('nostr-key-method') === 'android-signer') { + content = await amberSignerService.nip04Decrypt(store.state.pubkey.toHex(), list.content) + } + else{ + content = await this.signer.nip04Decrypt(store.state.pubkey, list.content) + console.log(content) + } + + let json = JSON.parse(content) for (let entry of json) { if (entry[0] === "p") { @@ -969,7 +978,7 @@ export default { //console.log(error) } - + } console.log("Overall mutes: " + mutelist.length) } store.commit('set_mutes', mutelist)