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 0323eda commit e5fb6bb
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 e5fb6bb

Please sign in to comment.