-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GAL-4161 refactor how comments are rendered to solve wrapping (#1986)
* refactor how comments are rendered to solve wrapping * update layout and refactor to Comments component * clean * usememo
- Loading branch information
Showing
10 changed files
with
159 additions
and
156 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
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,54 @@ | ||
import { View } from 'react-native'; | ||
import { graphql, useFragment } from 'react-relay'; | ||
|
||
import { GalleryTouchableOpacity } from '~/components/GalleryTouchableOpacity'; | ||
import { Typography } from '~/components/Typography'; | ||
import { CommentsFragment$key } from '~/generated/CommentsFragment.graphql'; | ||
|
||
import { CommentLine } from './CommentLine'; | ||
import { RemainingCommentCount } from './RemainingCommentCount'; | ||
import { useMemo } from 'react'; | ||
|
||
type Props = { | ||
commentRefs: CommentsFragment$key; | ||
totalComments: number; | ||
onCommentPress: () => void; | ||
}; | ||
|
||
export default function Comments({ commentRefs, totalComments, onCommentPress }: Props) { | ||
const comments = useFragment( | ||
graphql` | ||
fragment CommentsFragment on Comment @relay(plural: true) { | ||
dbid | ||
...CommentLineFragment | ||
} | ||
`, | ||
commentRefs | ||
); | ||
|
||
const previewComments = useMemo(() => comments.slice(-1), [comments]); | ||
|
||
return ( | ||
<View className="flex flex-col space-y-1"> | ||
{previewComments.map((comment) => { | ||
return ( | ||
<CommentLine key={comment.dbid} commentRef={comment} onCommentPress={onCommentPress} /> | ||
); | ||
})} | ||
|
||
{totalComments > 1 && ( | ||
<RemainingCommentCount totalCount={totalComments} onPress={onCommentPress} /> | ||
)} | ||
{totalComments === 0 && ( | ||
<GalleryTouchableOpacity onPress={onCommentPress} eventElementId={null} eventName={null}> | ||
<Typography | ||
font={{ family: 'ABCDiatype', weight: 'Regular' }} | ||
className="text-sm text-shadow" | ||
> | ||
Add a comment | ||
</Typography> | ||
</GalleryTouchableOpacity> | ||
)} | ||
</View> | ||
); | ||
} |
Oops, something went wrong.