From 21bfcc226d23a3368ded82c594ce340bc9d21a0e Mon Sep 17 00:00:00 2001 From: robertu <4065233+robertu7@users.noreply.github.com> Date: Mon, 6 Mar 2023 12:37:30 +0700 Subject: [PATCH] fix(article): private fetch article detail by node id --- src/views/ArticleDetail/gql.ts | 29 ++++++++++++++--------------- src/views/ArticleDetail/index.tsx | 4 ++-- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/src/views/ArticleDetail/gql.ts b/src/views/ArticleDetail/gql.ts index 86d8b97b6a..9b7c71174e 100644 --- a/src/views/ArticleDetail/gql.ts +++ b/src/views/ArticleDetail/gql.ts @@ -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} diff --git a/src/views/ArticleDetail/index.tsx b/src/views/ArticleDetail/index.tsx index 37c5a8efc5..0d0dee9e59 100644 --- a/src/views/ArticleDetail/index.tsx +++ b/src/views/ArticleDetail/index.tsx @@ -412,7 +412,7 @@ const ArticleDetail = ({ */ const [privateFetched, setPrivateFetched] = useState(false) const loadPrivate = async () => { - if (!viewer.isAuthed || !article || !article?.mediaHash) { + if (!viewer.isAuthed || !article) { return } @@ -420,7 +420,7 @@ const ArticleDetail = ({ query: ARTICLE_DETAIL_PRIVATE, fetchPolicy: 'network-only', variables: { - mediaHash: article?.mediaHash, + id: article?.id, includeCanSuperLike: viewer.isCivicLiker, }, })