Haptic on profile buttons (#6034)
* play haptic on profile buttons * change react import
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import React, {memo, useMemo} from 'react'
|
import {memo, useCallback, useMemo, useState} from 'react'
|
||||||
import {View} from 'react-native'
|
import {View} from 'react-native'
|
||||||
import {
|
import {
|
||||||
type AppBskyActorDefs,
|
type AppBskyActorDefs,
|
||||||
@@ -84,12 +84,10 @@ let ProfileHeaderLabeler = ({
|
|||||||
const {mutateAsync: likeMod, isPending: isLikePending} = useLikeMutation()
|
const {mutateAsync: likeMod, isPending: isLikePending} = useLikeMutation()
|
||||||
const {mutateAsync: unlikeMod, isPending: isUnlikePending} =
|
const {mutateAsync: unlikeMod, isPending: isUnlikePending} =
|
||||||
useUnlikeMutation()
|
useUnlikeMutation()
|
||||||
const [likeUri, setLikeUri] = React.useState<string>(
|
const [likeUri, setLikeUri] = useState<string>(labeler.viewer?.like || '')
|
||||||
labeler.viewer?.like || '',
|
const [likeCount, setLikeCount] = useState(labeler.likeCount || 0)
|
||||||
)
|
|
||||||
const [likeCount, setLikeCount] = React.useState(labeler.likeCount || 0)
|
|
||||||
|
|
||||||
const onToggleLiked = React.useCallback(async () => {
|
const onToggleLiked = useCallback(async () => {
|
||||||
if (!labeler) {
|
if (!labeler) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -118,9 +116,9 @@ let ProfileHeaderLabeler = ({
|
|||||||
|
|
||||||
const editProfileControl = useDialogControl()
|
const editProfileControl = useDialogControl()
|
||||||
|
|
||||||
const onPressSubscribe = React.useCallback(
|
const onPressSubscribe = useCallback(() => {
|
||||||
() =>
|
|
||||||
requireAuth(async (): Promise<void> => {
|
requireAuth(async (): Promise<void> => {
|
||||||
|
playHaptic()
|
||||||
const subscribe = !isSubscribed
|
const subscribe = !isSubscribed
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -144,18 +142,18 @@ let ProfileHeaderLabeler = ({
|
|||||||
}
|
}
|
||||||
logger.error(`Failed to subscribe to labeler`, {message: e.message})
|
logger.error(`Failed to subscribe to labeler`, {message: e.message})
|
||||||
}
|
}
|
||||||
}),
|
})
|
||||||
[
|
}, [
|
||||||
|
playHaptic,
|
||||||
requireAuth,
|
requireAuth,
|
||||||
toggleSubscription,
|
toggleSubscription,
|
||||||
isSubscribed,
|
isSubscribed,
|
||||||
profile,
|
profile,
|
||||||
cantSubscribePrompt,
|
cantSubscribePrompt,
|
||||||
reset,
|
reset,
|
||||||
],
|
])
|
||||||
)
|
|
||||||
|
|
||||||
const isMe = React.useMemo(
|
const isMe = useMemo(
|
||||||
() => currentAccount?.did === profile.did,
|
() => currentAccount?.did === profile.did,
|
||||||
[currentAccount, profile],
|
[currentAccount, profile],
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import {msg, Trans} from '@lingui/macro'
|
|||||||
import {useLingui} from '@lingui/react'
|
import {useLingui} from '@lingui/react'
|
||||||
|
|
||||||
import {useActorStatus} from '#/lib/actor-status'
|
import {useActorStatus} from '#/lib/actor-status'
|
||||||
|
import {useHaptics} from '#/lib/haptics'
|
||||||
import {sanitizeDisplayName} from '#/lib/strings/display-names'
|
import {sanitizeDisplayName} from '#/lib/strings/display-names'
|
||||||
import {sanitizeHandle} from '#/lib/strings/handles'
|
import {sanitizeHandle} from '#/lib/strings/handles'
|
||||||
import {logger} from '#/logger'
|
import {logger} from '#/logger'
|
||||||
@@ -79,12 +80,14 @@ let ProfileHeaderStandard = ({
|
|||||||
profile.viewer?.blocking ||
|
profile.viewer?.blocking ||
|
||||||
profile.viewer?.blockedBy ||
|
profile.viewer?.blockedBy ||
|
||||||
profile.viewer?.blockingByList
|
profile.viewer?.blockingByList
|
||||||
|
const playHaptic = useHaptics()
|
||||||
|
|
||||||
const editProfileControl = useDialogControl()
|
const editProfileControl = useDialogControl()
|
||||||
|
|
||||||
const onPressFollow = () => {
|
const onPressFollow = () => {
|
||||||
setShowSuggestedFollows(true)
|
playHaptic()
|
||||||
requireAuth(async () => {
|
requireAuth(async () => {
|
||||||
|
setShowSuggestedFollows(true)
|
||||||
try {
|
try {
|
||||||
await queueFollow()
|
await queueFollow()
|
||||||
Toast.show(
|
Toast.show(
|
||||||
@@ -105,6 +108,7 @@ let ProfileHeaderStandard = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const onPressUnfollow = () => {
|
const onPressUnfollow = () => {
|
||||||
|
playHaptic()
|
||||||
setShowSuggestedFollows(false)
|
setShowSuggestedFollows(false)
|
||||||
requireAuth(async () => {
|
requireAuth(async () => {
|
||||||
try {
|
try {
|
||||||
@@ -127,6 +131,7 @@ let ProfileHeaderStandard = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const unblockAccount = useCallback(async () => {
|
const unblockAccount = useCallback(async () => {
|
||||||
|
playHaptic()
|
||||||
try {
|
try {
|
||||||
await queueUnblock()
|
await queueUnblock()
|
||||||
Toast.show(_(msg({message: 'Account unblocked', context: 'toast'})))
|
Toast.show(_(msg({message: 'Account unblocked', context: 'toast'})))
|
||||||
@@ -136,7 +141,7 @@ let ProfileHeaderStandard = ({
|
|||||||
Toast.show(_(msg`There was an issue! ${e.toString()}`), 'xmark')
|
Toast.show(_(msg`There was an issue! ${e.toString()}`), 'xmark')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [_, queueUnblock])
|
}, [_, queueUnblock, playHaptic])
|
||||||
|
|
||||||
const isMe = useMemo(
|
const isMe = useMemo(
|
||||||
() => currentAccount?.did === profile.did,
|
() => currentAccount?.did === profile.did,
|
||||||
|
|||||||
Reference in New Issue
Block a user