Improve Android haptic, offer toggle for haptics in the app (#3482)
* improve android haptics, offer toggle for haptics * update haptics.ts * default to false * simplify to `playHaptic` * just leave them as `feedInfo` * use a hook for `playHaptic` * missed one of them
This commit is contained in:
parent
9007810cdb
commit
740cd029d7
14 changed files with 235 additions and 204 deletions
|
@ -27,7 +27,7 @@ import {truncateAndInvalidate} from '#/state/queries/util'
|
|||
import {useSession} from '#/state/session'
|
||||
import {useComposerControls} from '#/state/shell/composer'
|
||||
import {useAnalytics} from 'lib/analytics/analytics'
|
||||
import {Haptics} from 'lib/haptics'
|
||||
import {useHaptics} from 'lib/haptics'
|
||||
import {usePalette} from 'lib/hooks/usePalette'
|
||||
import {useSetTitle} from 'lib/hooks/useSetTitle'
|
||||
import {ComposeIcon2} from 'lib/icons'
|
||||
|
@ -159,6 +159,7 @@ export function ProfileFeedScreenInner({
|
|||
const reportDialogControl = useReportDialogControl()
|
||||
const {openComposer} = useComposerControls()
|
||||
const {track} = useAnalytics()
|
||||
const playHaptic = useHaptics()
|
||||
const feedSectionRef = React.useRef<SectionRef>(null)
|
||||
const isScreenFocused = useIsFocused()
|
||||
|
||||
|
@ -201,7 +202,7 @@ export function ProfileFeedScreenInner({
|
|||
|
||||
const onToggleSaved = React.useCallback(async () => {
|
||||
try {
|
||||
Haptics.default()
|
||||
playHaptic()
|
||||
|
||||
if (isSaved) {
|
||||
await removeFeed({uri: feedInfo.uri})
|
||||
|
@ -221,18 +222,19 @@ export function ProfileFeedScreenInner({
|
|||
logger.error('Failed up update feeds', {message: err})
|
||||
}
|
||||
}, [
|
||||
feedInfo,
|
||||
playHaptic,
|
||||
isSaved,
|
||||
saveFeed,
|
||||
removeFeed,
|
||||
resetSaveFeed,
|
||||
feedInfo,
|
||||
resetRemoveFeed,
|
||||
_,
|
||||
saveFeed,
|
||||
resetSaveFeed,
|
||||
])
|
||||
|
||||
const onTogglePinned = React.useCallback(async () => {
|
||||
try {
|
||||
Haptics.default()
|
||||
playHaptic()
|
||||
|
||||
if (isPinned) {
|
||||
await unpinFeed({uri: feedInfo.uri})
|
||||
|
@ -245,7 +247,16 @@ export function ProfileFeedScreenInner({
|
|||
Toast.show(_(msg`There was an issue contacting the server`))
|
||||
logger.error('Failed to toggle pinned feed', {message: e})
|
||||
}
|
||||
}, [isPinned, feedInfo, pinFeed, unpinFeed, resetPinFeed, resetUnpinFeed, _])
|
||||
}, [
|
||||
playHaptic,
|
||||
isPinned,
|
||||
unpinFeed,
|
||||
feedInfo,
|
||||
resetUnpinFeed,
|
||||
pinFeed,
|
||||
resetPinFeed,
|
||||
_,
|
||||
])
|
||||
|
||||
const onPressShare = React.useCallback(() => {
|
||||
const url = toShareUrl(feedInfo.route.href)
|
||||
|
@ -517,6 +528,7 @@ function AboutSection({
|
|||
const [likeUri, setLikeUri] = React.useState(feedInfo.likeUri)
|
||||
const {hasSession} = useSession()
|
||||
const {track} = useAnalytics()
|
||||
const playHaptic = useHaptics()
|
||||
const {mutateAsync: likeFeed, isPending: isLikePending} = useLikeMutation()
|
||||
const {mutateAsync: unlikeFeed, isPending: isUnlikePending} =
|
||||
useUnlikeMutation()
|
||||
|
@ -527,7 +539,7 @@ function AboutSection({
|
|||
|
||||
const onToggleLiked = React.useCallback(async () => {
|
||||
try {
|
||||
Haptics.default()
|
||||
playHaptic()
|
||||
|
||||
if (isLiked && likeUri) {
|
||||
await unlikeFeed({uri: likeUri})
|
||||
|
@ -546,7 +558,7 @@ function AboutSection({
|
|||
)
|
||||
logger.error('Failed up toggle like', {message: err})
|
||||
}
|
||||
}, [likeUri, isLiked, feedInfo, likeFeed, unlikeFeed, track, _])
|
||||
}, [playHaptic, isLiked, likeUri, unlikeFeed, track, likeFeed, feedInfo, _])
|
||||
|
||||
return (
|
||||
<View style={[styles.aboutSectionContainer]}>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue