Skip to content

Commit

Permalink
Add long press functionality to like button in PostCtrls
Browse files Browse the repository at this point in the history
  • Loading branch information
hichemfantar committed Jan 3, 2025
1 parent 615bbc3 commit 92b8788
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/view/com/util/post-ctrls/PostCtrls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ import {
} from '@atproto/api'
import {msg, plural} from '@lingui/macro'
import {useLingui} from '@lingui/react'
import {useNavigation} from '@react-navigation/native'

import {IS_INTERNAL} from '#/lib/app-info'
import {POST_CTRL_HITSLOP} from '#/lib/constants'
import {CountWheel} from '#/lib/custom-animations/CountWheel'
import {AnimatedLikeIcon} from '#/lib/custom-animations/LikeIcon'
import {useHaptics} from '#/lib/haptics'
import {makeProfileLink} from '#/lib/routes/links'
import {NavigationProp} from '#/lib/routes/types'
import {shareUrl} from '#/lib/sharing'
import {useGate} from '#/lib/statsig/statsig'
import {toShareUrl} from '#/lib/strings/url-helpers'
Expand Down Expand Up @@ -81,6 +83,7 @@ let PostCtrls = ({
post,
logContext,
)
const navigation = useNavigation<NavigationProp>()
const requireAuth = useRequireAuth()
const loggedOutWarningPromptControl = useDialogControl()
const {sendInteraction} = useFeedFeedbackContext()
Expand Down Expand Up @@ -152,6 +155,14 @@ let PostCtrls = ({
isBlocked,
])

const onLongPressToggleLike = React.useCallback(async () => {
const urip = new AtUri(post.uri)
navigation.navigate('PostLikedBy', {
name: post.author.handle,
rkey: urip.rkey,
})
}, [navigation, post.author.handle, post.uri])

const onRepost = useCallback(async () => {
if (isBlocked) {
Toast.show(
Expand Down Expand Up @@ -298,6 +309,7 @@ let PostCtrls = ({
testID="likeBtn"
style={btnStyle}
onPress={() => requireAuth(() => onPressToggleLike())}
onLongPress={() => onLongPressToggleLike()}
accessibilityRole="button"
accessibilityLabel={
post.viewer?.like
Expand Down

0 comments on commit 92b8788

Please sign in to comment.