Skip to content

Commit

Permalink
Merge pull request #3883 from thematters/hotfix/prefer-id-over-hash
Browse files Browse the repository at this point in the history
[hotfix - master] feat(article): prefer id over hash
  • Loading branch information
gary02 authored Oct 10, 2023
2 parents 0323eda + e5fb6bb commit 6c9fd67
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 6c9fd67

Please sign in to comment.