-
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.
* Add optimistic video reactions * Add initial implementation for comment optimistic actions * Add initial implementation for comment optimistic actions * Initial changes for comments reactions * Improve comments layout * Fix first comment reaction update * Avoid refetch on comment reactions * Disallow certain actions if comment is unconfirmed * Bring back joystream total earnings query
- Loading branch information
Showing
15 changed files
with
844 additions
and
202 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
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
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.