From 09eae80f3e3ed2756a207368df83799fd176be07 Mon Sep 17 00:00:00 2001 From: Innei Date: Mon, 23 Sep 2024 19:35:14 +0800 Subject: [PATCH] feat: compatible profile query by username Signed-off-by: Innei --- .../pages/(external)/(with-layout)/profile/[id]/index.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/renderer/src/pages/(external)/(with-layout)/profile/[id]/index.tsx b/apps/renderer/src/pages/(external)/(with-layout)/profile/[id]/index.tsx index 9a65cd621..63934f83a 100644 --- a/apps/renderer/src/pages/(external)/(with-layout)/profile/[id]/index.tsx +++ b/apps/renderer/src/pages/(external)/(with-layout)/profile/[id]/index.tsx @@ -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, }, })