Skip to content

Commit

Permalink
feat: launch show all comments feature to all user
Browse files Browse the repository at this point in the history
  • Loading branch information
teodorus-nathaniel committed Jan 31, 2024
1 parent 6816eb8 commit 6d01779
Showing 1 changed file with 9 additions and 17 deletions.
26 changes: 9 additions & 17 deletions src/components/comments/CommentsSection.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Checkbox } from 'antd'
import clsx from 'clsx'
import { FC } from 'react'
import { useIsMyAddressWhitelisted } from 'src/config/constants'
import { PostWithSomeDetails, SpaceStruct } from 'src/types'
import useLocalStorage from 'use-local-storage'
import { useIsMyAddress } from '../auth/MyAccountsContext'
Expand Down Expand Up @@ -31,16 +30,11 @@ export const CommentSection: FC<CommentSectionProps> = ({
const { id, repliesCount, ownerId } = struct
const isPostAuthor = useIsMyAddress(ownerId)

const isWhitelisted = useIsMyAddressWhitelisted()
let [showAllComments, setShowAllComments] = useLocalStorage<boolean>('showAllComments', false, {
parser: str => str === 'true',
serializer: bool => String(bool),
})

if (!isWhitelisted) {
showAllComments = true
}

return (
<Section
id={hashId}
Expand All @@ -52,17 +46,15 @@ export const CommentSection: FC<CommentSectionProps> = ({
<h3>
<Pluralize count={repliesCount || 0} singularText='comment' />
</h3>
{isWhitelisted && (
<Checkbox
checked={showAllComments}
style={{ marginRight: '-8px' }}
onChange={e => setShowAllComments(e.target.checked)}
>
<span className='ColorMuted' style={{ userSelect: 'none' }}>
Show all comments
</span>
</Checkbox>
)}
<Checkbox
checked={showAllComments}
style={{ marginRight: '-8px' }}
onChange={e => setShowAllComments(e.target.checked)}
>
<span className='ColorMuted' style={{ userSelect: 'none' }}>
Show all comments
</span>
</Checkbox>
</div>
<NewComment post={struct} asStub eventProps={{ eventSource, level: 0, isPostAuthor }} />
<ViewCommentsTree
Expand Down

0 comments on commit 6d01779

Please sign in to comment.