Skip to content

Commit

Permalink
Update FeedItem.tsx
Browse files Browse the repository at this point in the history
  • Loading branch information
quiple committed Jul 8, 2024
1 parent 6e2b295 commit d0a2e26
Showing 1 changed file with 43 additions and 17 deletions.
60 changes: 43 additions & 17 deletions src/view/com/notifications/FeedItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {msg, Plural, Trans} from '@lingui/macro'
import {useLingui} from '@lingui/react'
import {useQueryClient} from '@tanstack/react-query'

import {useGate} from '#/lib/statsig/statsig'
import {FeedNotification} from '#/state/queries/notifications/feed'
import {useAnimatedValue} from 'lib/hooks/useAnimatedValue'
import {usePalette} from 'lib/hooks/usePalette'
Expand Down Expand Up @@ -86,6 +87,7 @@ let FeedItem = ({
const pal = usePalette('default')
const {_} = useLingui()
const t = useTheme()
const gate = useGate()
const [isAuthorsExpanded, setAuthorsExpanded] = useState<boolean>(false)
const itemHref = useMemo(() => {
if (item.type === 'post-like' || item.type === 'repost') {
Expand Down Expand Up @@ -168,6 +170,7 @@ let FeedItem = ({
)
}

let isFollowBack = false
let formattedCount = authors.length > 1 ? formatCount(authors.length - 1) : ''

let author = (
Expand Down Expand Up @@ -229,22 +232,45 @@ let FeedItem = ({
)
icon = <RepostIcon size="xl" style={{color: t.palette.positive_600}} />
} else if (item.type === 'follow') {
action =
authors.length > 1 ? (
<Trans>
{author} and{' '}
<Text style={[pal.text, s.bold]}>
<Plural
value={authors.length - 1}
one={`${formattedCount} other`}
other={`${formattedCount} others`}
/>
</Text>{' '}
followed you
</Trans>
) : (
<Trans>{author} followed you</Trans>
)
if (
item.notification.author.viewer?.following &&
gate('ungroup_follow_backs')
) {
isFollowBack = true
action =
authors.length > 1 ? (
<Trans>
{author} and{' '}
<Text style={[pal.text, s.bold]}>
<Plural
value={authors.length - 1}
one={`${formattedCount} other`}
other={`${formattedCount} others`}
/>
</Text>{' '}
followed you back
</Trans>
) : (
<Trans>{author} followed you back</Trans>
)
} else {
action =
authors.length > 1 ? (
<Trans>
{author} and{' '}
<Text style={[pal.text, s.bold]}>
<Plural
value={authors.length - 1}
one={`${formattedCount} other`}
other={`${formattedCount} others`}
/>
</Text>{' '}
followed you
</Trans>
) : (
<Trans>{author} followed you</Trans>
)
}
icon = <PersonPlusIcon size="xl" style={{color: t.palette.primary_500}} />
} else if (item.type === 'feedgen-like') {
action =
Expand Down Expand Up @@ -349,7 +375,7 @@ let FeedItem = ({
visible={!isAuthorsExpanded}
authors={authors}
onToggleAuthorsExpanded={onToggleAuthorsExpanded}
showDmButton={item.type === 'starterpack-joined'}
showDmButton={item.type === 'starterpack-joined' || isFollowBack}
/>
<ExpandedAuthorsList visible={isAuthorsExpanded} authors={authors} />
<Text style={[styles.meta, pal.text]}>
Expand Down

0 comments on commit d0a2e26

Please sign in to comment.