From feab147fb952e38620453d8d88896a8bba296a13 Mon Sep 17 00:00:00 2001 From: Alejandro Gomez Date: Tue, 25 Jul 2023 16:30:53 +0200 Subject: [PATCH 1/4] fix: dont alter followed tags --- src/element/follow-button.tsx | 14 ++++++++------ src/hooks/follows.ts | 3 +-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/element/follow-button.tsx b/src/element/follow-button.tsx index 8d34fce..813086d 100644 --- a/src/element/follow-button.tsx +++ b/src/element/follow-button.tsx @@ -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]); diff --git a/src/hooks/follows.ts b/src/hooks/follows.ts index 657354d..c9d349c 100644 --- a/src/hooks/follows.ts +++ b/src/hooks/follows.ts @@ -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 }; } From 2ea8586d4052719d49d9906ab89753e392440fb5 Mon Sep 17 00:00:00 2001 From: Alejandro Gomez Date: Tue, 25 Jul 2023 16:31:15 +0200 Subject: [PATCH 2/4] fix: parse mentions in chatzaps --- src/element/live-chat.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/element/live-chat.tsx b/src/element/live-chat.tsx index 34a18fb..90bdae5 100644 --- a/src/element/live-chat.tsx +++ b/src/element/live-chat.tsx @@ -17,6 +17,7 @@ import { useLiveChatFeed } from "../hooks/live-chat"; import { Profile } from "./profile"; import { Icon } from "./icon"; import Spinner from "./spinner"; +import { Text } from "./text"; import { useLogin } from "../hooks/login"; import { formatSats } from "../number"; import useTopZappers from "../hooks/top-zappers"; @@ -201,7 +202,11 @@ function ChatZap({ zap }: { zap: ParsedZap }) { {formatSats(zap.amount)} sats - {zap.content &&
{zap.content}
} + {zap.content && ( +
+ +
+ )} ); } From 192f5cb600cc33be8b1039fb2669a00481009431 Mon Sep 17 00:00:00 2001 From: Alejandro Gomez Date: Tue, 25 Jul 2023 16:34:18 +0200 Subject: [PATCH 3/4] fix: wrap chatzap header --- src/element/live-chat.css | 1 + 1 file changed, 1 insertion(+) diff --git a/src/element/live-chat.css b/src/element/live-chat.css index e9b9bb6..2db6938 100644 --- a/src/element/live-chat.css +++ b/src/element/live-chat.css @@ -108,6 +108,7 @@ display: flex; align-items: center; gap: 8px; + flex-wrap: wrap; } .top-zappers { From 9e437c6425d2861540a4a43b6b59fa5d7e1214ea Mon Sep 17 00:00:00 2001 From: Alejandro Gomez Date: Tue, 25 Jul 2023 16:38:57 +0200 Subject: [PATCH 4/4] fix: disable follow button if no follow list available --- src/element/follow-button.tsx | 4 +++- src/hooks/follows.ts | 3 +-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/element/follow-button.tsx b/src/element/follow-button.tsx index 813086d..bf6bee4 100644 --- a/src/element/follow-button.tsx +++ b/src/element/follow-button.tsx @@ -12,7 +12,8 @@ export function LoggedInFollowButton({ pubkey: string; }) { const login = useLogin(); - const { tags, relays } = useFollows(loggedIn, true); + const following = useFollows(loggedIn, true); + const { tags, relays } = following ? following : { tags: [], relays: {} } const follows = tags.filter((t) => t.at(0) === "p") const isFollowing = follows.find((t) => t.at(1) === pubkey); @@ -52,6 +53,7 @@ export function LoggedInFollowButton({ return (