fix: dont alter followed tags
This commit is contained in:
@ -11,18 +11,20 @@ export function LoggedInFollowButton({
|
||||
loggedIn: string;
|
||||
pubkey: string;
|
||||
}) {
|
||||
const { contacts, relays } = useFollows(loggedIn, true);
|
||||
const login = useLogin();
|
||||
const isFollowing = contacts.find((t) => t.at(1) === pubkey);
|
||||
const { tags, relays } = useFollows(loggedIn, true);
|
||||
const follows = tags.filter((t) => t.at(0) === "p")
|
||||
const isFollowing = follows.find((t) => t.at(1) === pubkey);
|
||||
|
||||
async function unfollow() {
|
||||
const pub = login?.publisher();
|
||||
if (pub) {
|
||||
const ev = await pub.generic((eb) => {
|
||||
eb.kind(EventKind.ContactList).content(JSON.stringify(relays));
|
||||
for (const c of contacts) {
|
||||
if (c.at(1) !== pubkey) {
|
||||
eb.tag(c);
|
||||
for (const t of tags) {
|
||||
const isFollow = t.at(0) === "p" && t.at(1) === pubkey
|
||||
if (!isFollow) {
|
||||
eb.tag(t);
|
||||
}
|
||||
}
|
||||
return eb;
|
||||
@ -37,7 +39,7 @@ export function LoggedInFollowButton({
|
||||
if (pub) {
|
||||
const ev = await pub.generic((eb) => {
|
||||
eb.kind(EventKind.ContactList).content(JSON.stringify(relays));
|
||||
for (const tag of contacts) {
|
||||
for (const tag of tags) {
|
||||
eb.tag(tag);
|
||||
}
|
||||
eb.tag(["p", pubkey]);
|
||||
|
@ -21,8 +21,7 @@ export default function useFollows(pubkey: string, leaveOpen = false) {
|
||||
sub
|
||||
);
|
||||
|
||||
const contacts = (data?.tags ?? []).filter((t) => t.at(0) === "p");
|
||||
const relays = JSON.parse(data?.content ?? "{}");
|
||||
|
||||
return { contacts, relays };
|
||||
return { tags: data?.tags ?? [], relays };
|
||||
}
|
||||
|
Reference in New Issue
Block a user