Skip to content

Commit

Permalink
feat(article): prefer to fetch article detail data by articleId inste…
Browse files Browse the repository at this point in the history
…ad of mediaHash
  • Loading branch information
robertu7 authored and gary committed Oct 10, 2023
1 parent 18ab421 commit c0003a6
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/views/ArticleDetail/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down Expand Up @@ -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<ArticleAvailableTranslationsQuery>(
ARTICLE_AVAILABLE_TRANSLATIONS,
{ variables: { mediaHash }, skip: !isQueryByHash }
Expand Down

0 comments on commit c0003a6

Please sign in to comment.