From e5fb6bb5dd84c8e54ca0e650b53be212bbb1c8af Mon Sep 17 00:00:00 2001 From: robertu <4065233+robertu7@users.noreply.github.com> Date: Tue, 10 Oct 2023 16:03:32 +0700 Subject: [PATCH] feat(article): prefer to fetch article detail data by articleId instead of mediaHash --- src/views/ArticleDetail/index.tsx | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/views/ArticleDetail/index.tsx b/src/views/ArticleDetail/index.tsx index 0ba07e02c4..7909cdc692 100644 --- a/src/views/ArticleDetail/index.tsx +++ b/src/views/ArticleDetail/index.tsx @@ -380,7 +380,11 @@ const ArticleDetail = ({ /** * fetch public data */ - const isQueryByHash = !!(mediaHash && isMediaHashPossiblyValid(mediaHash)) + const isQueryByHash = !!( + mediaHash && + isMediaHashPossiblyValid(mediaHash) && + !articleId + ) // backward compatible with: // - `/:username:/:articleId:-:slug:-:mediaHash` @@ -607,7 +611,12 @@ const ArticleDetailOuter = () => { const articleId = (router.query.mediaHash as string)?.match(/^(\d+)/)?.[1] || '' - const isQueryByHash = !!(mediaHash && isMediaHashPossiblyValid(mediaHash)) + const isQueryByHash = !!( + mediaHash && + isMediaHashPossiblyValid(mediaHash) && + !articleId + ) + const resultByHash = usePublicQuery( ARTICLE_AVAILABLE_TRANSLATIONS, { variables: { mediaHash }, skip: !isQueryByHash }