make onReply callbacks non reactive
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import {memo, useCallback, useMemo} from 'react'
|
import {memo, useMemo} from 'react'
|
||||||
import {Text as RNText, View} from 'react-native'
|
import {Text as RNText, View} from 'react-native'
|
||||||
import {
|
import {
|
||||||
AppBskyFeedDefs,
|
AppBskyFeedDefs,
|
||||||
@@ -9,6 +9,7 @@ import {
|
|||||||
} from '@atproto/api'
|
} from '@atproto/api'
|
||||||
import {Plural, Trans, useLingui} from '@lingui/react/macro'
|
import {Plural, Trans, useLingui} from '@lingui/react/macro'
|
||||||
|
|
||||||
|
import {useNonReactiveCallback} from '#/lib/hooks/useNonReactiveCallback'
|
||||||
import {useOpenComposer} from '#/lib/hooks/useOpenComposer'
|
import {useOpenComposer} from '#/lib/hooks/useOpenComposer'
|
||||||
import {makeProfileLink} from '#/lib/routes/links'
|
import {makeProfileLink} from '#/lib/routes/links'
|
||||||
import {sanitizeDisplayName} from '#/lib/strings/display-names'
|
import {sanitizeDisplayName} from '#/lib/strings/display-names'
|
||||||
@@ -245,7 +246,7 @@ const ThreadItemAnchorInner = memo(function ThreadItemAnchorInner({
|
|||||||
}
|
}
|
||||||
}, [postSource])
|
}, [postSource])
|
||||||
|
|
||||||
const onPressReply = useCallback(() => {
|
const onPressReply = useNonReactiveCallback(() => {
|
||||||
openComposer({
|
openComposer({
|
||||||
replyTo: {
|
replyTo: {
|
||||||
uri: post.uri,
|
uri: post.uri,
|
||||||
@@ -268,15 +269,7 @@ const ThreadItemAnchorInner = memo(function ThreadItemAnchorInner({
|
|||||||
reqId: postSource.post.reqId,
|
reqId: postSource.post.reqId,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}, [
|
})
|
||||||
openComposer,
|
|
||||||
post,
|
|
||||||
record,
|
|
||||||
onPostSuccess,
|
|
||||||
moderation,
|
|
||||||
postSource,
|
|
||||||
feedFeedback,
|
|
||||||
])
|
|
||||||
|
|
||||||
const onOpenAuthor = () => {
|
const onOpenAuthor = () => {
|
||||||
ax.metric('post:clickthroughAuthor', {
|
ax.metric('post:clickthroughAuthor', {
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import Animated, {useAnimatedStyle} from 'react-native-reanimated'
|
|||||||
import {Trans} from '@lingui/react/macro'
|
import {Trans} from '@lingui/react/macro'
|
||||||
|
|
||||||
import {useInitialNumToRender} from '#/lib/hooks/useInitialNumToRender'
|
import {useInitialNumToRender} from '#/lib/hooks/useInitialNumToRender'
|
||||||
|
import {useNonReactiveCallback} from '#/lib/hooks/useNonReactiveCallback'
|
||||||
import {useOpenComposer} from '#/lib/hooks/useOpenComposer'
|
import {useOpenComposer} from '#/lib/hooks/useOpenComposer'
|
||||||
import {usePostViewTracking} from '#/lib/hooks/usePostViewTracking'
|
import {usePostViewTracking} from '#/lib/hooks/usePostViewTracking'
|
||||||
import {useFeedFeedback} from '#/state/feed-feedback'
|
import {useFeedFeedback} from '#/state/feed-feedback'
|
||||||
@@ -105,7 +106,7 @@ export function PostThread({uri}: {uri: string}) {
|
|||||||
const trackThreadItemView = usePostViewTracking('PostThreadItem')
|
const trackThreadItemView = usePostViewTracking('PostThreadItem')
|
||||||
|
|
||||||
const {openComposer} = useOpenComposer()
|
const {openComposer} = useOpenComposer()
|
||||||
const optimisticOnPostReply = useCallback(
|
const optimisticOnPostReply = useNonReactiveCallback(
|
||||||
(payload: OnPostSuccessData) => {
|
(payload: OnPostSuccessData) => {
|
||||||
if (payload) {
|
if (payload) {
|
||||||
const {replyToUri, posts} = payload
|
const {replyToUri, posts} = payload
|
||||||
@@ -114,9 +115,8 @@ export function PostThread({uri}: {uri: string}) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[thread],
|
|
||||||
)
|
)
|
||||||
const onReplyToAnchor = useCallback(() => {
|
const onReplyToAnchor = useNonReactiveCallback(() => {
|
||||||
if (anchor?.type !== 'threadPost') {
|
if (anchor?.type !== 'threadPost') {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -143,13 +143,7 @@ export function PostThread({uri}: {uri: string}) {
|
|||||||
reqId: anchorPostSource.post.reqId,
|
reqId: anchorPostSource.post.reqId,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}, [
|
})
|
||||||
anchor,
|
|
||||||
openComposer,
|
|
||||||
optimisticOnPostReply,
|
|
||||||
anchorPostSource,
|
|
||||||
feedFeedback,
|
|
||||||
])
|
|
||||||
|
|
||||||
const isRoot = !!anchor && anchor.value.post.record.reply === undefined
|
const isRoot = !!anchor && anchor.value.post.record.reply === undefined
|
||||||
const canReply = !anchor?.value.post?.viewer?.replyDisabled
|
const canReply = !anchor?.value.post?.viewer?.replyDisabled
|
||||||
|
|||||||
Reference in New Issue
Block a user