-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6370 from ikprk/release/5.3.0
- Loading branch information
Showing
53 changed files
with
1,026 additions
and
1,633 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { QueryHookOptions } from '@apollo/client' | ||
|
||
import { UNCONFIRMED } from '@/hooks/useOptimisticActions' | ||
import { createLookup } from '@/utils/data' | ||
|
||
import { | ||
GetUserCommentsAndVideoCommentsConnectionQuery, | ||
GetUserCommentsAndVideoCommentsConnectionQueryVariables, | ||
useGetUserCommentsAndVideoCommentsConnectionQuery, | ||
} from '../queries/__generated__/comments.generated' | ||
|
||
export const useCommentSectionComments = ( | ||
variables?: GetUserCommentsAndVideoCommentsConnectionQueryVariables, | ||
opts?: QueryHookOptions< | ||
GetUserCommentsAndVideoCommentsConnectionQuery, | ||
GetUserCommentsAndVideoCommentsConnectionQueryVariables | ||
> | ||
) => { | ||
const { data, loading, ...rest } = useGetUserCommentsAndVideoCommentsConnectionQuery({ ...opts, variables }) | ||
const userComments = data?.userComments | ||
const userCommentLookup = data?.userComments && createLookup(data?.userComments) | ||
const unconfirmedComments = data?.videoCommentsConnection.edges | ||
.map((edge) => edge.node) | ||
.filter((node) => node.id.includes(UNCONFIRMED)) | ||
const unconfirmedCommentLookup = unconfirmedComments && createLookup(unconfirmedComments) | ||
|
||
const videoComments = data?.videoCommentsConnection?.edges | ||
.map((edge) => edge.node) | ||
.filter((comment) => userCommentLookup && !userCommentLookup[comment.id] && !unconfirmedCommentLookup?.[comment.id]) | ||
|
||
return { | ||
userComments, | ||
comments: data ? [...(unconfirmedComments || []), ...(userComments || []), ...(videoComments || [])] : undefined, | ||
loading: loading, | ||
pageInfo: data?.videoCommentsConnection?.pageInfo, | ||
...rest, | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
packages/atlas/src/api/queries/__generated__/comments.generated.tsx
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.