feat: add follow user button in profile modal (#1147)

Co-authored-by: Stephen Zhou <38493346+hyoban@users.noreply.github.com>
This commit is contained in:
cos
2024-10-26 12:39:27 +08:00
committed by GitHub
co-authored by Stephen Zhou
parent b867af9b45
commit 7c60d5e91d
3 changed files with 32 additions and 4 deletions
@@ -60,15 +60,18 @@ export const UserProfileModalContent: FC<{
avatar: user.data.image,
name: user.data.name,
handle: user.data.handle,
id: user.data.id,
}
: storeUser
? {
avatar: storeUser.image,
name: storeUser.name,
handle: storeUser.handle,
id: storeUser.id,
}
: null
const follow = useFollow()
const subscriptions = useUserSubscriptionsQuery(user.data?.id)
const modal = useCurrentModal()
const controller = useAnimationControls()
@@ -270,16 +273,27 @@ export const UserProfileModalContent: FC<{
>
<m.h1 layout>{userInfo.name}</m.h1>
</m.div>
<m.div
className={cn(
"mb-0 text-sm text-zinc-500",
"text-sm text-zinc-500",
userInfo.handle ? "visible" : "hidden select-none",
)}
layout
>
@{userInfo.handle}
</m.div>
<Button
buttonClassName="mt-2"
onClick={() => {
follow({
url: `rsshub://follow/profile/${userInfo.id}`,
isList: false,
})
}}
>
<FollowIcon className="mr-1 size-3" />
{t("feed_form.follow")}
</Button>
</m.div>
</div>
<ScrollArea.ScrollArea
@@ -27,6 +27,7 @@ export const Component = () => {
const isMe = user.data?.id === me?.id
const { t } = useTranslation("common")
return (
<MainContainer className="items-center">
{user.isLoading ? (
@@ -40,12 +41,24 @@ export const Component = () => {
/>
<AvatarFallback>{user.data?.name?.slice(0, 2)}</AvatarFallback>
</Avatar>
<div className="flex flex-col items-center">
<div className="mb-8 flex flex-col items-center">
<div className="mb-2 mt-4 flex items-center text-2xl font-bold">
<h1>{user.data?.name}</h1>
</div>
{user.data?.handle && (
<div className="mb-8 text-sm text-zinc-500">@{user.data.handle}</div>
<div className="mb-2 text-sm text-zinc-500">@{user.data.handle}</div>
)}
{user.data?.id && (
<Button
onClick={() => {
openInFollowApp(`add?url=rsshub://follow/profile/${user.data?.id}`, () => {
window.location.href = `rsshub://follow/profile/${user.data?.id}`
})
}}
>
<FollowIcon className="mr-1 size-3" />
{t("words.follow")}
</Button>
)}
</div>
<div
+1
View File
@@ -21,6 +21,7 @@
"words.edit": "Edit",
"words.entry": "Entry",
"words.expand": "Expand",
"words.follow": "Follow",
"words.id": "ID",
"words.items_one": "Item",
"words.items_other": "Items",