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
|
@ -16,7 +16,6 @@ import {msg} from '@lingui/macro'
|
|||
import {useLingui} from '@lingui/react'
|
||||
|
||||
import {HITSLOP_10, HITSLOP_20} from '#/lib/constants'
|
||||
import {Haptics} from '#/lib/haptics'
|
||||
import {CommentBottomArrow, HeartIcon, HeartIconSolid} from '#/lib/icons'
|
||||
import {makeProfileLink} from '#/lib/routes/links'
|
||||
import {shareUrl} from '#/lib/sharing'
|
||||
|
@ -32,6 +31,7 @@ import {
|
|||
} from '#/state/queries/post'
|
||||
import {useRequireAuth} from '#/state/session'
|
||||
import {useComposerControls} from '#/state/shell/composer'
|
||||
import {useHaptics} from 'lib/haptics'
|
||||
import {useDialogControl} from '#/components/Dialog'
|
||||
import {ArrowOutOfBox_Stroke2_Corner0_Rounded as ArrowOutOfBox} from '#/components/icons/ArrowOutOfBox'
|
||||
import * as Prompt from '#/components/Prompt'
|
||||
|
@ -67,6 +67,7 @@ let PostCtrls = ({
|
|||
)
|
||||
const requireAuth = useRequireAuth()
|
||||
const loggedOutWarningPromptControl = useDialogControl()
|
||||
const playHaptic = useHaptics()
|
||||
|
||||
const shouldShowLoggedOutWarning = React.useMemo(() => {
|
||||
return !!post.author.labels?.find(
|
||||
|
@ -84,7 +85,7 @@ let PostCtrls = ({
|
|||
const onPressToggleLike = React.useCallback(async () => {
|
||||
try {
|
||||
if (!post.viewer?.like) {
|
||||
Haptics.default()
|
||||
playHaptic()
|
||||
await queueLike()
|
||||
} else {
|
||||
await queueUnlike()
|
||||
|
@ -94,13 +95,13 @@ let PostCtrls = ({
|
|||
throw e
|
||||
}
|
||||
}
|
||||
}, [post.viewer?.like, queueLike, queueUnlike])
|
||||
}, [playHaptic, post.viewer?.like, queueLike, queueUnlike])
|
||||
|
||||
const onRepost = useCallback(async () => {
|
||||
closeModal()
|
||||
try {
|
||||
if (!post.viewer?.repost) {
|
||||
Haptics.default()
|
||||
playHaptic()
|
||||
await queueRepost()
|
||||
} else {
|
||||
await queueUnrepost()
|
||||
|
@ -110,7 +111,7 @@ let PostCtrls = ({
|
|||
throw e
|
||||
}
|
||||
}
|
||||
}, [post.viewer?.repost, queueRepost, queueUnrepost, closeModal])
|
||||
}, [closeModal, post.viewer?.repost, playHaptic, queueRepost, queueUnrepost])
|
||||
|
||||
const onQuote = useCallback(() => {
|
||||
closeModal()
|
||||
|
@ -123,15 +124,16 @@ let PostCtrls = ({
|
|||
indexedAt: post.indexedAt,
|
||||
},
|
||||
})
|
||||
Haptics.default()
|
||||
playHaptic()
|
||||
}, [
|
||||
closeModal,
|
||||
openComposer,
|
||||
post.uri,
|
||||
post.cid,
|
||||
post.author,
|
||||
post.indexedAt,
|
||||
record.text,
|
||||
openComposer,
|
||||
closeModal,
|
||||
playHaptic,
|
||||
])
|
||||
|
||||
const onShare = useCallback(() => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue