forked from Kieran/zap.stream
fix: disable follow button if no follow list available
This commit is contained in:
parent
192f5cb600
commit
9e437c6425
@ -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 (
|
||||
<AsyncButton
|
||||
disabled={!following}
|
||||
type="button"
|
||||
className="btn btn-primary"
|
||||
onClick={isFollowing ? unfollow : follow}
|
||||
|
@ -22,6 +22,5 @@ export default function useFollows(pubkey: string, leaveOpen = false) {
|
||||
);
|
||||
|
||||
const relays = JSON.parse(data?.content ?? "{}");
|
||||
|
||||
return { tags: data?.tags ?? [], relays };
|
||||
return data ? { tags: data.tags, relays } : null
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user