From 0462f09ecc18be53a7f31f0250a01eea1d20b3ed Mon Sep 17 00:00:00 2001 From: Joel Date: Tue, 27 Jun 2023 18:40:24 +0800 Subject: [PATCH] fix: app nav call detail match explore app detail page (#469) --- web/app/components/header/app-nav/index.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/web/app/components/header/app-nav/index.tsx b/web/app/components/header/app-nav/index.tsx index 414e2d4387..d811be3e3e 100644 --- a/web/app/components/header/app-nav/index.tsx +++ b/web/app/components/header/app-nav/index.tsx @@ -1,6 +1,6 @@ import { useCallback, useState } from 'react' import { useTranslation } from 'react-i18next' -import { useParams } from 'next/navigation' +import { useParams, usePathname } from 'next/navigation' import useSWR from 'swr' import useSWRInfinite from 'swr/infinite' import { flatten } from 'lodash-es' @@ -21,7 +21,8 @@ const AppNav = () => { const { t } = useTranslation() const [showNewAppDialog, setShowNewAppDialog] = useState(false) const { appId } = useParams() - const { data: currentApp } = useSWR(appId ? { url: '/apps', id: appId } : null, fetchAppDetail) + const isAppDetailPage = usePathname().split('/').includes('app') + const { data: currentApp } = useSWR((appId && isAppDetailPage) ? { url: '/apps', id: appId } : null, fetchAppDetail) const { data: appsData, setSize } = useSWRInfinite(appId ? getKey : () => null, fetchAppList, { revalidateFirstPage: false }) const appItems = flatten(appsData?.map(appData => appData.data))