Rename
This commit is contained in:
+15
-15
@@ -1,4 +1,4 @@
|
|||||||
import React, {useMemo} from 'react'
|
import {memo,useCallback, useMemo} from 'react'
|
||||||
import {type GestureResponderEvent, Text as RNText, View} from 'react-native'
|
import {type GestureResponderEvent, Text as RNText, View} from 'react-native'
|
||||||
import {
|
import {
|
||||||
type AppBskyFeedDefs,
|
type AppBskyFeedDefs,
|
||||||
@@ -60,7 +60,7 @@ import {VerificationCheckButton} from '#/components/verification/VerificationChe
|
|||||||
import {WhoCanReply} from '#/components/WhoCanReply'
|
import {WhoCanReply} from '#/components/WhoCanReply'
|
||||||
import * as bsky from '#/types/bsky'
|
import * as bsky from '#/types/bsky'
|
||||||
|
|
||||||
export function ThreadAnchor({
|
export function ThreadItemAnchor({
|
||||||
item,
|
item,
|
||||||
onPostSuccess,
|
onPostSuccess,
|
||||||
threadgateRecord,
|
threadgateRecord,
|
||||||
@@ -74,11 +74,11 @@ export function ThreadAnchor({
|
|||||||
const isRoot = threadRootUri === item.uri
|
const isRoot = threadRootUri === item.uri
|
||||||
|
|
||||||
if (postShadow === POST_TOMBSTONE) {
|
if (postShadow === POST_TOMBSTONE) {
|
||||||
return <PostThreadItemDeleted isRoot={isRoot} />
|
return <ThreadItemAnchorDeleted isRoot={isRoot} />
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PostThreadItemLoaded
|
<ThreadItemAnchorInner
|
||||||
// Safeguard from clobbering per-post state below:
|
// Safeguard from clobbering per-post state below:
|
||||||
key={postShadow.uri}
|
key={postShadow.uri}
|
||||||
item={item}
|
item={item}
|
||||||
@@ -90,7 +90,7 @@ export function ThreadAnchor({
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function PostThreadItemDeleted({isRoot}: {isRoot: boolean}) {
|
function ThreadItemAnchorDeleted({isRoot}: {isRoot: boolean}) {
|
||||||
const t = useTheme()
|
const t = useTheme()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -155,7 +155,7 @@ function ThreadItemAnchorParentReplyLine({isRoot}: {isRoot: boolean}) {
|
|||||||
) : null
|
) : null
|
||||||
}
|
}
|
||||||
|
|
||||||
let PostThreadItemLoaded = ({
|
const ThreadItemAnchorInner = memo(function ThreadItemAnchorInner({
|
||||||
item,
|
item,
|
||||||
isRoot,
|
isRoot,
|
||||||
postShadow,
|
postShadow,
|
||||||
@@ -167,7 +167,7 @@ let PostThreadItemLoaded = ({
|
|||||||
postShadow: Shadow<AppBskyFeedDefs.PostView>
|
postShadow: Shadow<AppBskyFeedDefs.PostView>
|
||||||
onPostSuccess?: (data: OnPostSuccessData) => void
|
onPostSuccess?: (data: OnPostSuccessData) => void
|
||||||
threadgateRecord?: AppBskyFeedThreadgate.Record
|
threadgateRecord?: AppBskyFeedThreadgate.Record
|
||||||
}): React.ReactNode => {
|
}) {
|
||||||
const t = useTheme()
|
const t = useTheme()
|
||||||
const {_, i18n} = useLingui()
|
const {_, i18n} = useLingui()
|
||||||
const {openComposer} = useOpenComposer()
|
const {openComposer} = useOpenComposer()
|
||||||
@@ -192,15 +192,15 @@ let PostThreadItemLoaded = ({
|
|||||||
const authorTitle = post.author.handle
|
const authorTitle = post.author.handle
|
||||||
const isThreadAuthor = getThreadAuthor(post, record) === currentAccount?.did
|
const isThreadAuthor = getThreadAuthor(post, record) === currentAccount?.did
|
||||||
|
|
||||||
const likesHref = React.useMemo(() => {
|
const likesHref = useMemo(() => {
|
||||||
const urip = new AtUri(post.uri)
|
const urip = new AtUri(post.uri)
|
||||||
return makeProfileLink(post.author, 'post', urip.rkey, 'liked-by')
|
return makeProfileLink(post.author, 'post', urip.rkey, 'liked-by')
|
||||||
}, [post.uri, post.author])
|
}, [post.uri, post.author])
|
||||||
const repostsHref = React.useMemo(() => {
|
const repostsHref = useMemo(() => {
|
||||||
const urip = new AtUri(post.uri)
|
const urip = new AtUri(post.uri)
|
||||||
return makeProfileLink(post.author, 'post', urip.rkey, 'reposted-by')
|
return makeProfileLink(post.author, 'post', urip.rkey, 'reposted-by')
|
||||||
}, [post.uri, post.author])
|
}, [post.uri, post.author])
|
||||||
const quotesHref = React.useMemo(() => {
|
const quotesHref = useMemo(() => {
|
||||||
const urip = new AtUri(post.uri)
|
const urip = new AtUri(post.uri)
|
||||||
return makeProfileLink(post.author, 'post', urip.rkey, 'quotes')
|
return makeProfileLink(post.author, 'post', urip.rkey, 'quotes')
|
||||||
}, [post.uri, post.author])
|
}, [post.uri, post.author])
|
||||||
@@ -208,7 +208,7 @@ let PostThreadItemLoaded = ({
|
|||||||
const threadgateHiddenReplies = useMergedThreadgateHiddenReplies({
|
const threadgateHiddenReplies = useMergedThreadgateHiddenReplies({
|
||||||
threadgateRecord,
|
threadgateRecord,
|
||||||
})
|
})
|
||||||
const additionalPostAlerts: AppModerationCause[] = React.useMemo(() => {
|
const additionalPostAlerts: AppModerationCause[] = useMemo(() => {
|
||||||
const isPostHiddenByThreadgate = threadgateHiddenReplies.has(post.uri)
|
const isPostHiddenByThreadgate = threadgateHiddenReplies.has(post.uri)
|
||||||
const isControlledByViewer =
|
const isControlledByViewer =
|
||||||
new AtUri(threadRootUri).host === currentAccount?.did
|
new AtUri(threadRootUri).host === currentAccount?.did
|
||||||
@@ -228,7 +228,7 @@ let PostThreadItemLoaded = ({
|
|||||||
const showFollowButton =
|
const showFollowButton =
|
||||||
currentAccount?.did !== post.author.did && !onlyFollowersCanReply
|
currentAccount?.did !== post.author.did && !onlyFollowersCanReply
|
||||||
|
|
||||||
const onPressReply = React.useCallback(() => {
|
const onPressReply = useCallback(() => {
|
||||||
openComposer({
|
openComposer({
|
||||||
replyTo: {
|
replyTo: {
|
||||||
uri: post.uri,
|
uri: post.uri,
|
||||||
@@ -425,7 +425,7 @@ let PostThreadItemLoaded = ({
|
|||||||
</View>
|
</View>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
})
|
||||||
|
|
||||||
function ExpandedPostDetails({
|
function ExpandedPostDetails({
|
||||||
post,
|
post,
|
||||||
@@ -452,7 +452,7 @@ function ExpandedPostDetails({
|
|||||||
[post, langPrefs.primaryLanguage],
|
[post, langPrefs.primaryLanguage],
|
||||||
)
|
)
|
||||||
|
|
||||||
const onTranslatePress = React.useCallback(
|
const onTranslatePress = useCallback(
|
||||||
(e: GestureResponderEvent) => {
|
(e: GestureResponderEvent) => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
openLink(translatorUrl, true)
|
openLink(translatorUrl, true)
|
||||||
@@ -609,7 +609,7 @@ function getThreadAuthor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function ThreadAnchorSkeleton() {
|
export function ThreadItemAnchorSkeleton() {
|
||||||
return (
|
return (
|
||||||
<View style={[a.p_lg, a.gap_md]}>
|
<View style={[a.p_lg, a.gap_md]}>
|
||||||
<Skele.Row style={[a.align_center, a.gap_md]}>
|
<Skele.Row style={[a.align_center, a.gap_md]}>
|
||||||
@@ -15,11 +15,11 @@ import {type OnPostSuccessData} from '#/state/shell/composer'
|
|||||||
import {PostThreadComposePrompt} from '#/view/com/post-thread/PostThreadComposePrompt'
|
import {PostThreadComposePrompt} from '#/view/com/post-thread/PostThreadComposePrompt'
|
||||||
import {List, type ListMethods} from '#/view/com/util/List'
|
import {List, type ListMethods} from '#/view/com/util/List'
|
||||||
import {HeaderDropdown} from '#/screens/PostThread/components/HeaderDropdown'
|
import {HeaderDropdown} from '#/screens/PostThread/components/HeaderDropdown'
|
||||||
import {
|
|
||||||
ThreadAnchor,
|
|
||||||
ThreadAnchorSkeleton,
|
|
||||||
} from '#/screens/PostThread/components/ThreadAnchor'
|
|
||||||
import {ThreadError} from '#/screens/PostThread/components/ThreadError'
|
import {ThreadError} from '#/screens/PostThread/components/ThreadError'
|
||||||
|
import {
|
||||||
|
ThreadItemAnchor,
|
||||||
|
ThreadItemAnchorSkeleton,
|
||||||
|
} from '#/screens/PostThread/components/ThreadItemAnchor'
|
||||||
import {ThreadItemAnchorNoUnauthenticated} from '#/screens/PostThread/components/ThreadItemAnchorNoUnauthenticated'
|
import {ThreadItemAnchorNoUnauthenticated} from '#/screens/PostThread/components/ThreadItemAnchorNoUnauthenticated'
|
||||||
import {
|
import {
|
||||||
ThreadItemPost,
|
ThreadItemPost,
|
||||||
@@ -378,7 +378,7 @@ export function PostThread({uri}: {uri: string | undefined}) {
|
|||||||
ref={anchorRef}
|
ref={anchorRef}
|
||||||
onLayout={() => setDeferParents(false)}
|
onLayout={() => setDeferParents(false)}
|
||||||
/>
|
/>
|
||||||
<ThreadAnchor
|
<ThreadItemAnchor
|
||||||
item={item}
|
item={item}
|
||||||
threadgateRecord={thread.data.threadgate?.record ?? undefined}
|
threadgateRecord={thread.data.threadgate?.record ?? undefined}
|
||||||
onPostSuccess={optimisticOnPostReply}
|
onPostSuccess={optimisticOnPostReply}
|
||||||
@@ -441,7 +441,7 @@ export function PostThread({uri}: {uri: string | undefined}) {
|
|||||||
return <ThreadItemShowOtherReplies onPress={item.onPress} />
|
return <ThreadItemShowOtherReplies onPress={item.onPress} />
|
||||||
} else if (item.type === 'skeleton') {
|
} else if (item.type === 'skeleton') {
|
||||||
if (item.item === 'anchor') {
|
if (item.item === 'anchor') {
|
||||||
return <ThreadAnchorSkeleton />
|
return <ThreadItemAnchorSkeleton />
|
||||||
} else if (item.item === 'reply') {
|
} else if (item.item === 'reply') {
|
||||||
if (thread.state.view === 'linear') {
|
if (thread.state.view === 'linear') {
|
||||||
return <ThreadItemPostSkeleton index={index} />
|
return <ThreadItemPostSkeleton index={index} />
|
||||||
|
|||||||
Reference in New Issue
Block a user