mirror of
https://github.com/hzrd149/nostrudel.git
synced 2025-04-12 21:59:16 +02:00
Show "Follow Back" on follow button
This commit is contained in:
parent
80eda9145a
commit
3ae7fe675c
5
.changeset/forty-fireants-stare.md
Normal file
5
.changeset/forty-fireants-stare.md
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"nostrudel": minor
|
||||||
|
---
|
||||||
|
|
||||||
|
Show "Follow Back" on follow button is user is following you
|
@ -2,6 +2,10 @@ import { Button, ButtonProps } from "@chakra-ui/react";
|
|||||||
import { useCurrentAccount } from "../hooks/use-current-account";
|
import { useCurrentAccount } from "../hooks/use-current-account";
|
||||||
import useSubject from "../hooks/use-subject";
|
import useSubject from "../hooks/use-subject";
|
||||||
import clientFollowingService from "../services/client-following";
|
import clientFollowingService from "../services/client-following";
|
||||||
|
import { useAsync } from "react-use";
|
||||||
|
import { NostrRequest } from "../classes/nostr-request";
|
||||||
|
import clientRelaysService from "../services/client-relays";
|
||||||
|
import { useUserContacts } from "../hooks/use-user-contacts";
|
||||||
|
|
||||||
export const UserFollowButton = ({
|
export const UserFollowButton = ({
|
||||||
pubkey,
|
pubkey,
|
||||||
@ -13,6 +17,8 @@ export const UserFollowButton = ({
|
|||||||
|
|
||||||
const isFollowing = following.some((t) => t[1] === pubkey);
|
const isFollowing = following.some((t) => t[1] === pubkey);
|
||||||
|
|
||||||
|
const userContacts = useUserContacts(pubkey, clientRelaysService.getReadUrls());
|
||||||
|
|
||||||
const toggleFollow = async () => {
|
const toggleFollow = async () => {
|
||||||
if (isFollowing) {
|
if (isFollowing) {
|
||||||
clientFollowingService.removeContact(pubkey);
|
clientFollowingService.removeContact(pubkey);
|
||||||
@ -25,7 +31,7 @@ export const UserFollowButton = ({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Button colorScheme="brand" {...props} isLoading={savingDraft} onClick={toggleFollow} isDisabled={account.readonly}>
|
<Button colorScheme="brand" {...props} isLoading={savingDraft} onClick={toggleFollow} isDisabled={account.readonly}>
|
||||||
{isFollowing ? "Unfollow" : "Follow"}
|
{isFollowing ? "Unfollow" : userContacts?.contacts.includes(account.pubkey) ? "Follow Back" : "Follow"}
|
||||||
</Button>
|
</Button>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user