better buttons and ln address on profile

This commit is contained in:
Alejandro Gomez
2023-01-10 12:27:28 +01:00
parent b32f3544cc
commit e6abbcbc44
7 changed files with 108 additions and 34 deletions

View File

@ -3,9 +3,11 @@ import useEventPublisher from "../feed/EventPublisher";
export default function FollowButton(props) {
const pubkey = props.pubkey;
const className = props.className ? `btn ${props.className}` : "btn";
const publiser = useEventPublisher();
const follows = useSelector(s => s.login.follows);
let isFollowing = follows?.includes(pubkey) ?? false;
const baseClassName = isFollowing ? `btn btn-warn` : `btn btn-success`
const className = props.className ? `${baseClassName} ${props.className}` : `${baseClassName}`;
async function follow(pubkey) {
let ev = await publiser.addFollow(pubkey);
@ -17,7 +19,6 @@ export default function FollowButton(props) {
publiser.broadcast(ev);
}
let isFollowing = follows?.includes(pubkey) ?? false;
return (
<div className={className} onClick={() => isFollowing ? unfollow(pubkey) : follow(pubkey)}>
{isFollowing ? "Unfollow" : "Follow"}