Skip to content

Commit

Permalink
[replies] Fix reply list page 500 error
Browse files Browse the repository at this point in the history
  • Loading branch information
MrOrz committed Mar 5, 2020
1 parent 72818d6 commit 4b0a15c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
2 changes: 2 additions & 0 deletions components/ReplyItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,12 @@ ReplyItem.fragments = {
type
createdAt
user {
id
name
}
articleReplies(status: NORMAL) {
articleId
replyId
}
}
`,
Expand Down
19 changes: 8 additions & 11 deletions pages/replies.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,7 @@ function ReplyListPage() {
orderBy: urlQuery2OrderBy(query),
};

const {
loading,
data: { ListReplies: replyData },
} = useQuery(LIST_REPLIES, {
const { loading, data: listRepliesData } = useQuery(LIST_REPLIES, {
variables: {
...listQueryVars,
before: query.before,
Expand All @@ -185,15 +182,15 @@ function ReplyListPage() {
// Separate these stats query so that it will be cached by apollo-client and sends no network request
// on page change, but still works when filter options are updated.

const {
loading: statsLoading,
data: { ListReplies: statsData },
} = useQuery(LIST_STAT, {
const { loading: statsLoading, data: listStatData } = useQuery(LIST_STAT, {
variables: listQueryVars,
});

const currentUser = useCurrentUser();

const replyEdges = listRepliesData?.ListReplies?.edges || [];
const statsData = listStatData?.ListReplies || {};

return (
<AppLayout>
<Head>
Expand Down Expand Up @@ -261,17 +258,17 @@ function ReplyListPage() {
<Pagination
query={query}
pageInfo={statsData?.pageInfo}
edges={replyData?.edges}
edges={replyEdges}
/>
<ul className="reply-list">
{replyData.edges.map(({ node }) => (
{replyEdges.map(({ node }) => (
<ReplyItem key={node.id} reply={node} showUser={!query.mine} />
))}
</ul>
<Pagination
query={query}
pageInfo={statsData?.pageInfo}
edges={replyData?.edges}
edges={replyEdges}
/>
</>
)}
Expand Down

0 comments on commit 4b0a15c

Please sign in to comment.