From 940796735058f2a8d3957386ef70b5827120289b Mon Sep 17 00:00:00 2001 From: Kechicode <186776112+Kechicode@users.noreply.github.com> Date: Wed, 27 Nov 2024 17:34:01 +0800 Subject: [PATCH 1/2] feat(TagDetail): Hide tag feed tabs when no hottest articles --- src/views/TagDetail/gql.ts | 3 +++ src/views/TagDetail/index.tsx | 3 ++- src/views/TagDetail/styles.module.css | 4 ++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/views/TagDetail/gql.ts b/src/views/TagDetail/gql.ts index c37e5936fa..8f30da9c90 100644 --- a/src/views/TagDetail/gql.ts +++ b/src/views/TagDetail/gql.ts @@ -15,6 +15,9 @@ const tagFragment = gql` } ...ArticleCountTag ...TagBookmarkButtonTagPrivate + hottestArticles: articles(input: { first: 10, sortBy: byHottestDesc }) { + totalCount + } recommended(input: { first: 10 }) { edges { cursor diff --git a/src/views/TagDetail/index.tsx b/src/views/TagDetail/index.tsx index 1d7cc8c748..9b501072ec 100644 --- a/src/views/TagDetail/index.tsx +++ b/src/views/TagDetail/index.tsx @@ -63,6 +63,7 @@ const TagDetail = ({ tag }: { tag: TagFragmentFragment }) => { const isHottest = feedType === 'hottest' const isLatest = feedType === 'latest' const hasArticles = tag.numArticles > 0 + const hasHottestArticles = tag.hottestArticles.totalCount > 0 useEffect(() => { // backward compatible with `/tags/:globalId:` @@ -128,7 +129,7 @@ const TagDetail = ({ tag }: { tag: TagFragmentFragment }) => { - {hasArticles && ( + {hasArticles && hasHottestArticles && (
Date: Wed, 27 Nov 2024 20:31:15 +0800 Subject: [PATCH 2/2] fix(TagDetail): Optimize tag detail query by reducing hottestArticles fetch size --- src/views/TagDetail/gql.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/views/TagDetail/gql.ts b/src/views/TagDetail/gql.ts index 8f30da9c90..5898869933 100644 --- a/src/views/TagDetail/gql.ts +++ b/src/views/TagDetail/gql.ts @@ -15,7 +15,7 @@ const tagFragment = gql` } ...ArticleCountTag ...TagBookmarkButtonTagPrivate - hottestArticles: articles(input: { first: 10, sortBy: byHottestDesc }) { + hottestArticles: articles(input: { first: 0, sortBy: byHottestDesc }) { totalCount } recommended(input: { first: 10 }) {