mirror of
https://github.com/believethehype/nostrdvm.git
synced 2025-11-22 02:57:08 +01:00
show following status in recommendation feed
This commit is contained in:
@@ -2,14 +2,14 @@
|
|||||||
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Client,
|
Client, ClientBuilder, Contact,
|
||||||
Duration,
|
Duration,
|
||||||
Event,
|
Event,
|
||||||
EventBuilder,
|
EventBuilder,
|
||||||
Filter,
|
Filter,
|
||||||
Keys,
|
Keys, NostrDatabase,
|
||||||
NostrSigner,
|
NostrSigner, Options,
|
||||||
PublicKey,
|
PublicKey, RelayLimits,
|
||||||
Tag,
|
Tag,
|
||||||
Timestamp,
|
Timestamp,
|
||||||
UnsignedEvent
|
UnsignedEvent
|
||||||
@@ -1017,12 +1017,42 @@ async function mute(result) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
async function unfollow(result){
|
async function unfollow(result){
|
||||||
let client = store.state.client
|
let dbclient = Client
|
||||||
|
let keys = Keys.parse(store.state.nooglekey)
|
||||||
|
let signer = NostrSigner.keys(keys)
|
||||||
|
let limits = RelayLimits.disable()
|
||||||
|
let relayopts = new Options().relayLimits(limits);
|
||||||
|
dbclient = new ClientBuilder().signer(signer).opts(relayopts).build()
|
||||||
|
await dbclient.addRelay("wss://relay.damus.io");
|
||||||
|
await dbclient.addRelay( "wss://purplepag.es");
|
||||||
|
await dbclient.connect()
|
||||||
console.log(result.authorid)
|
console.log(result.authorid)
|
||||||
let found = false
|
let found = false
|
||||||
let element
|
let element
|
||||||
for (let em of store.state.contacts){
|
let publicKey = store.state.pubkey
|
||||||
|
console.log(publicKey.toHex())
|
||||||
|
let followers_filter = new Filter().author(publicKey).kind(3).limit(1)
|
||||||
|
let followers = await dbclient.getEventsOf([followers_filter], Duration.fromSecs(5))
|
||||||
|
console.log(followers.length)
|
||||||
|
let contacts = []
|
||||||
|
|
||||||
|
if (followers.length > 0){
|
||||||
|
for (let tag of followers[0].tags) {
|
||||||
|
if (tag.asVec()[0] === "p") {
|
||||||
|
let contact = new Contact(PublicKey.parse(tag.asVec()[1]), tag.asVec()[2], tag.asVec()[3])
|
||||||
|
contacts.push(contact)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
console.log(contacts)
|
||||||
|
for (let em of contacts){
|
||||||
if (em.publicKey.toHex() === result.authorid){
|
if (em.publicKey.toHex() === result.authorid){
|
||||||
found = true
|
found = true
|
||||||
element = em
|
element = em
|
||||||
@@ -1035,19 +1065,22 @@ async function unfollow(result){
|
|||||||
if (found){
|
if (found){
|
||||||
|
|
||||||
console.log(element)
|
console.log(element)
|
||||||
let index = store.state.contacts.indexOf(element)
|
let index = contacts.indexOf(element)
|
||||||
console.log(index)
|
console.log(index)
|
||||||
console.log(store.state.contacts.length)
|
console.log(contacts.length)
|
||||||
|
|
||||||
let rm = store.state.contacts.splice(index, 1)
|
let rm = contacts.splice(index, 1)
|
||||||
|
|
||||||
|
|
||||||
try{
|
try{
|
||||||
let event = EventBuilder.contactList(store.state.contacts).toUnsignedEvent(store.state.pubkey)
|
|
||||||
let signedevent = await store.state.signer.signEvent(event)
|
|
||||||
let requestid = await client.sendEvent(signedevent);
|
|
||||||
|
|
||||||
console.log("unfollow logic for " + result.event.profile.name + " " + requestid.toHex())
|
let event = EventBuilder.contactList(contacts)
|
||||||
|
let client = store.state.client
|
||||||
|
let requestid = await client.sendEventBuilder(event);
|
||||||
|
|
||||||
|
console.log("unfollowing " + result.event.profile.name + " " + requestid.toHex())
|
||||||
|
console.log( contacts)
|
||||||
|
store.commit('set_contacts', contacts)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
catch(error){
|
catch(error){
|
||||||
@@ -1059,7 +1092,7 @@ async function unfollow(result){
|
|||||||
console.log("not found")
|
console.log("not found")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}}
|
||||||
|
|
||||||
async function store_nwc(){
|
async function store_nwc(){
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
<img class="avatar" v-else src="@/assets/nostr-purple.svg" />
|
<img class="avatar" v-else src="@/assets/nostr-purple.svg" />
|
||||||
|
|
||||||
<a class="purple" :href="authorurl" target="_blank">{{ author }}</a>
|
<a class="purple" :href="authorurl" target="_blank">{{ author }}</a>
|
||||||
|
<a className="white" style="background: #1f2937; font-size: xx-small" v-if="store.state.followings.find(x => x == authorid) !== undefined">Following</a>
|
||||||
<div class="time">
|
<div class="time">
|
||||||
{{indicator.time.split("T")[1].split("Z")[0].trim()}}
|
{{indicator.time.split("T")[1].split("Z")[0].trim()}}
|
||||||
{{indicator.time.split("T")[0].split("-")[2].trim()}}.{{indicator.time.split("T")[0].split("-")[1].trim()}}.{{indicator.time.split("T")[0].split("-")[0].trim().slice(2)}}
|
{{indicator.time.split("T")[0].split("-")[2].trim()}}.{{indicator.time.split("T")[0].split("-")[1].trim()}}.{{indicator.time.split("T")[0].split("-")[0].trim().slice(2)}}
|
||||||
@@ -196,6 +197,9 @@ async function react(eventid, authorid, evt){
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
async function reply (eventid, authorid, message){
|
async function reply (eventid, authorid, message){
|
||||||
|
|
||||||
console.log(eventid)
|
console.log(eventid)
|
||||||
|
|||||||
Reference in New Issue
Block a user