Skip to content

Commit

Permalink
Merge pull request #3242 from thematters/fix/article-private-fetch
Browse files Browse the repository at this point in the history
[hotfix - master] fix(article): private fetch article detail by node id
  • Loading branch information
robertu7 authored Mar 6, 2023
2 parents 961c2a8 + 21bfcc2 commit 1b01a71
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 deletions.
29 changes: 14 additions & 15 deletions src/views/ArticleDetail/gql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,25 +134,24 @@ export const ARTICLE_DETAIL_PUBLIC_BY_NODE_ID = gql`
`

export const ARTICLE_DETAIL_PRIVATE = gql`
query ArticleDetailPrivate(
$mediaHash: String!
$includeCanSuperLike: Boolean!
) {
article(input: { mediaHash: $mediaHash }) {
id
content
author {
query ArticleDetailPrivate($id: ID!, $includeCanSuperLike: Boolean!) {
article: node(input: { id: $id }) {
... on Article {
id
...UserDigestRichUserPrivate
}
access {
circle {
content
author {
id
...CircleWallCirclePrivate
...UserDigestRichUserPrivate
}
access {
circle {
id
...CircleWallCirclePrivate
}
}
...ToolbarArticlePrivate
...SupportWidgetArticlePrivate
}
...ToolbarArticlePrivate
...SupportWidgetArticlePrivate
}
}
${UserDigest.Rich.fragments.user.private}
Expand Down
4 changes: 2 additions & 2 deletions src/views/ArticleDetail/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -412,15 +412,15 @@ const ArticleDetail = ({
*/
const [privateFetched, setPrivateFetched] = useState(false)
const loadPrivate = async () => {
if (!viewer.isAuthed || !article || !article?.mediaHash) {
if (!viewer.isAuthed || !article) {
return
}

await client.query({
query: ARTICLE_DETAIL_PRIVATE,
fetchPolicy: 'network-only',
variables: {
mediaHash: article?.mediaHash,
id: article?.id,
includeCanSuperLike: viewer.isCivicLiker,
},
})
Expand Down

0 comments on commit 1b01a71

Please sign in to comment.