Skip to content

Commit

Permalink
fix(exteral): edit or follow in web app when login
Browse files Browse the repository at this point in the history
Signed-off-by: Innei <i@innei.in>
  • Loading branch information
Innei committed Sep 16, 2024
1 parent 7e8f462 commit 0ccadf7
Showing 1 changed file with 29 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ import { FollowIcon } from "@renderer/components/icons/follow"
import { Avatar, AvatarFallback, AvatarImage } from "@renderer/components/ui/avatar"
import { Button } from "@renderer/components/ui/button"
import { LoadingCircle } from "@renderer/components/ui/loading"
import { useModalStack } from "@renderer/components/ui/modal"
import { useAuthQuery, useI18n, useTitle } from "@renderer/hooks/common"
import { apiClient } from "@renderer/lib/api-fetch"
import { defineQuery } from "@renderer/lib/defineQuery"
import { stopPropagation } from "@renderer/lib/dom"
import { cn } from "@renderer/lib/utils"
import { FeedForm } from "@renderer/modules/discover/feed-form"
import { useUserSubscriptionsQuery } from "@renderer/modules/profile/hooks"
import { DEEPLINK_SCHEME } from "@shared/constants"
import { useParams } from "react-router-dom"
Expand All @@ -34,6 +35,7 @@ export function Component() {
useTitle(user.data?.name)
const me = useWhoami()
const isMe = user.data?.id === me?.id
const { present } = useModalStack()

return user.isLoading ? (
<LoadingCircle size="large" className="center h-48 w-full max-w-full" />
Expand Down Expand Up @@ -78,24 +80,33 @@ export function Component() {
{subscription.feeds?.description}
</div>
</div>

<a
className="absolute right-0 opacity-0 transition-opacity group-hover:opacity-100"
href={`${DEEPLINK_SCHEME}add?id=${subscription.feeds?.id}`}
onClick={stopPropagation}
>
<Button>
{isMe ? (
t.common("words.edit")
) : (
<>
<FollowIcon className="mr-1 size-3" />
{APP_NAME}
</>
)}
</Button>
</a>
</a>
<span className="center absolute inset-y-0 right-0 opacity-0 transition-opacity group-hover:opacity-100">
<Button
onClick={(e) => {
e.stopPropagation()
if (me) {
present({
title: t("sidebar.feed_actions.edit_feed"),
content: ({ dismiss }) => (
<FeedForm asWidget id={subscription.feedId} onSuccess={dismiss} />
),
})
} else {
window.location.href = `${DEEPLINK_SCHEME}add?id=${subscription.feeds?.id}`
}
}}
>
{isMe ? (
t.common("words.edit")
) : (
<>
<FollowIcon className="mr-1 size-3" />
{APP_NAME}
</>
)}
</Button>
</span>
</div>
))}
</div>
Expand Down

0 comments on commit 0ccadf7

Please sign in to comment.