play haptics before closing modal (#4283)
parent
b077cbe399
commit
16925baf8d
|
@ -23,7 +23,6 @@ import {toShareUrl} from '#/lib/strings/url-helpers'
|
||||||
import {s} from '#/lib/styles'
|
import {s} from '#/lib/styles'
|
||||||
import {Shadow} from '#/state/cache/types'
|
import {Shadow} from '#/state/cache/types'
|
||||||
import {useFeedFeedbackContext} from '#/state/feed-feedback'
|
import {useFeedFeedbackContext} from '#/state/feed-feedback'
|
||||||
import {useModalControls} from '#/state/modals'
|
|
||||||
import {
|
import {
|
||||||
usePostLikeMutationQueue,
|
usePostLikeMutationQueue,
|
||||||
usePostRepostMutationQueue,
|
usePostRepostMutationQueue,
|
||||||
|
@ -65,7 +64,6 @@ let PostCtrls = ({
|
||||||
const t = useTheme()
|
const t = useTheme()
|
||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
const {openComposer} = useComposerControls()
|
const {openComposer} = useComposerControls()
|
||||||
const {closeModal} = useModalControls()
|
|
||||||
const [queueLike, queueUnlike] = usePostLikeMutationQueue(post, logContext)
|
const [queueLike, queueUnlike] = usePostLikeMutationQueue(post, logContext)
|
||||||
const [queueRepost, queueUnrepost] = usePostRepostMutationQueue(
|
const [queueRepost, queueUnrepost] = usePostRepostMutationQueue(
|
||||||
post,
|
post,
|
||||||
|
@ -118,10 +116,8 @@ let PostCtrls = ({
|
||||||
])
|
])
|
||||||
|
|
||||||
const onRepost = useCallback(async () => {
|
const onRepost = useCallback(async () => {
|
||||||
closeModal()
|
|
||||||
try {
|
try {
|
||||||
if (!post.viewer?.repost) {
|
if (!post.viewer?.repost) {
|
||||||
playHaptic()
|
|
||||||
sendInteraction({
|
sendInteraction({
|
||||||
item: post.uri,
|
item: post.uri,
|
||||||
event: 'app.bsky.feed.defs#interactionRepost',
|
event: 'app.bsky.feed.defs#interactionRepost',
|
||||||
|
@ -137,10 +133,8 @@ let PostCtrls = ({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [
|
}, [
|
||||||
closeModal,
|
|
||||||
post.uri,
|
post.uri,
|
||||||
post.viewer?.repost,
|
post.viewer?.repost,
|
||||||
playHaptic,
|
|
||||||
queueRepost,
|
queueRepost,
|
||||||
queueUnrepost,
|
queueUnrepost,
|
||||||
sendInteraction,
|
sendInteraction,
|
||||||
|
@ -148,7 +142,6 @@ let PostCtrls = ({
|
||||||
])
|
])
|
||||||
|
|
||||||
const onQuote = useCallback(() => {
|
const onQuote = useCallback(() => {
|
||||||
closeModal()
|
|
||||||
sendInteraction({
|
sendInteraction({
|
||||||
item: post.uri,
|
item: post.uri,
|
||||||
event: 'app.bsky.feed.defs#interactionQuote',
|
event: 'app.bsky.feed.defs#interactionQuote',
|
||||||
|
@ -163,16 +156,13 @@ let PostCtrls = ({
|
||||||
indexedAt: post.indexedAt,
|
indexedAt: post.indexedAt,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
playHaptic()
|
|
||||||
}, [
|
}, [
|
||||||
closeModal,
|
|
||||||
openComposer,
|
openComposer,
|
||||||
post.uri,
|
post.uri,
|
||||||
post.cid,
|
post.cid,
|
||||||
post.author,
|
post.author,
|
||||||
post.indexedAt,
|
post.indexedAt,
|
||||||
record.text,
|
record.text,
|
||||||
playHaptic,
|
|
||||||
sendInteraction,
|
sendInteraction,
|
||||||
feedContext,
|
feedContext,
|
||||||
])
|
])
|
||||||
|
|
|
@ -3,6 +3,7 @@ import {View} from 'react-native'
|
||||||
import {msg, plural} from '@lingui/macro'
|
import {msg, plural} from '@lingui/macro'
|
||||||
import {useLingui} from '@lingui/react'
|
import {useLingui} from '@lingui/react'
|
||||||
|
|
||||||
|
import {useHaptics} from '#/lib/haptics'
|
||||||
import {useRequireAuth} from '#/state/session'
|
import {useRequireAuth} from '#/state/session'
|
||||||
import {atoms as a, useTheme} from '#/alf'
|
import {atoms as a, useTheme} from '#/alf'
|
||||||
import {Button, ButtonText} from '#/components/Button'
|
import {Button, ButtonText} from '#/components/Button'
|
||||||
|
@ -30,6 +31,7 @@ let RepostButton = ({
|
||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
const requireAuth = useRequireAuth()
|
const requireAuth = useRequireAuth()
|
||||||
const dialogControl = Dialog.useDialogControl()
|
const dialogControl = Dialog.useDialogControl()
|
||||||
|
const playHaptic = useHaptics()
|
||||||
|
|
||||||
const color = React.useMemo(
|
const color = React.useMemo(
|
||||||
() => ({
|
() => ({
|
||||||
|
@ -89,8 +91,11 @@ let RepostButton = ({
|
||||||
: _(msg({message: `Repost`, context: 'action'}))
|
: _(msg({message: `Repost`, context: 'action'}))
|
||||||
}
|
}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
dialogControl.close()
|
if (!isReposted) playHaptic()
|
||||||
onRepost()
|
|
||||||
|
dialogControl.close(() => {
|
||||||
|
onRepost()
|
||||||
|
})
|
||||||
}}
|
}}
|
||||||
size="large"
|
size="large"
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
|
@ -106,6 +111,7 @@ let RepostButton = ({
|
||||||
style={[a.justify_start, a.px_md]}
|
style={[a.justify_start, a.px_md]}
|
||||||
label={_(msg`Quote post`)}
|
label={_(msg`Quote post`)}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
|
playHaptic()
|
||||||
dialogControl.close(() => {
|
dialogControl.close(() => {
|
||||||
onQuote()
|
onQuote()
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue