feat: compatible profile query by username
Signed-off-by: Innei <i@innei.in>
This commit is contained in:
@@ -12,19 +12,19 @@ import { usePresentFeedFormModal } from "~/hooks/biz/useFeedFormModal"
|
||||
import { useAuthQuery, useI18n, useTitle } from "~/hooks/common"
|
||||
import { apiClient } from "~/lib/api-fetch"
|
||||
import { defineQuery } from "~/lib/defineQuery"
|
||||
import { cn } from "~/lib/utils"
|
||||
import { cn, isBizId } from "~/lib/utils"
|
||||
import { useUserSubscriptionsQuery } from "~/modules/profile/hooks"
|
||||
|
||||
export function Component() {
|
||||
const t = useI18n()
|
||||
const { id } = useParams()
|
||||
|
||||
const isHandle = id?.startsWith("@")
|
||||
const isHandle = id ? id.startsWith("@") || !isBizId(id) : false
|
||||
const user = useAuthQuery(
|
||||
defineQuery(["profiles", id], async () => {
|
||||
const res = await apiClient.profiles.$get({
|
||||
query: {
|
||||
handle: isHandle ? id?.slice(1) : undefined,
|
||||
handle: isHandle ? (id?.startsWith("@") ? id.slice(1) : id) : undefined,
|
||||
id: isHandle ? undefined : id,
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user