diff options
author | Eric Bailey <git@esb.lol> | 2025-06-11 13:22:02 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-06-11 13:22:02 -0500 |
commit | 143d5f3b814f1ce707fdfc87dabff7af5349bd06 (patch) | |
tree | 86cd639d45da0c994f8bf1d9160b1a8497f53e0c /src/view/com/post-thread | |
parent | 7341294df6156afdf24ab43e1e27ebba94f265ad (diff) | |
download | voidsky-143d5f3b814f1ce707fdfc87dabff7af5349bd06.tar.zst |
Post source handling updates (#8472)
* Add debugs * Key post-source using URI with handle * Enhance * EnHANCE * ENHANCE * ENHANCEEEECEE * ᵉⁿʰᵃⁿᶜᵉ * enhance
Diffstat (limited to 'src/view/com/post-thread')
-rw-r--r-- | src/view/com/post-thread/PostThread.tsx | 30 | ||||
-rw-r--r-- | src/view/com/post-thread/PostThreadItem.tsx | 34 |
2 files changed, 44 insertions, 20 deletions
diff --git a/src/view/com/post-thread/PostThread.tsx b/src/view/com/post-thread/PostThread.tsx index d974ce6b5..5bec9ced1 100644 --- a/src/view/com/post-thread/PostThread.tsx +++ b/src/view/com/post-thread/PostThread.tsx @@ -22,6 +22,7 @@ import {ScrollProvider} from '#/lib/ScrollContext' import {sanitizeDisplayName} from '#/lib/strings/display-names' import {cleanError} from '#/lib/strings/errors' import {isAndroid, isNative, isWeb} from '#/platform/detection' +import {useFeedFeedback} from '#/state/feed-feedback' import {useModerationOpts} from '#/state/preferences/moderation-opts' import { fillThreadModerationCache, @@ -37,6 +38,7 @@ import {useSetThreadViewPreferencesMutation} from '#/state/queries/preferences' import {usePreferencesQuery} from '#/state/queries/preferences' import {useSession} from '#/state/session' import {useMergedThreadgateHiddenReplies} from '#/state/threadgate-hidden-replies' +import {useUnstablePostSource} from '#/state/unstable-post-source' import {List, type ListMethods} from '#/view/com/util/List' import {atoms as a, useTheme} from '#/alf' import {Button, ButtonIcon} from '#/components/Button' @@ -93,7 +95,7 @@ const keyExtractor = (item: RowItem) => { return item._reactKey } -export function PostThread({uri}: {uri: string | undefined}) { +export function PostThread({uri}: {uri: string}) { const {hasSession, currentAccount} = useSession() const {_} = useLingui() const t = useTheme() @@ -104,6 +106,8 @@ export function PostThread({uri}: {uri: string | undefined}) { HiddenRepliesState.Hide, ) const headerRef = React.useRef<View | null>(null) + const anchorPostSource = useUnstablePostSource(uri) + const feedFeedback = useFeedFeedback(anchorPostSource?.feed, hasSession) const {data: preferences} = usePreferencesQuery() const { @@ -395,10 +399,18 @@ export function PostThread({uri}: {uri: string | undefined}) { ) const {openComposer} = useOpenComposer() - const onPressReply = React.useCallback(() => { + const onReplyToAnchor = React.useCallback(() => { if (thread?.type !== 'post') { return } + if (anchorPostSource) { + feedFeedback.sendInteraction({ + item: thread.post.uri, + event: 'app.bsky.feed.defs#interactionReply', + feedContext: anchorPostSource.post.feedContext, + reqId: anchorPostSource.post.reqId, + }) + } openComposer({ replyTo: { uri: thread.post.uri, @@ -410,7 +422,14 @@ export function PostThread({uri}: {uri: string | undefined}) { }, onPost: onPostReply, }) - }, [openComposer, thread, onPostReply, threadModerationCache]) + }, [ + openComposer, + thread, + onPostReply, + threadModerationCache, + anchorPostSource, + feedFeedback, + ]) const canReply = !error && rootPost && !rootPost.viewer?.replyDisabled const hasParents = @@ -423,7 +442,7 @@ export function PostThread({uri}: {uri: string | undefined}) { return ( <View> {!isMobile && ( - <PostThreadComposePrompt onPressCompose={onPressReply} /> + <PostThreadComposePrompt onPressCompose={onReplyToAnchor} /> )} </View> ) @@ -511,6 +530,7 @@ export function PostThread({uri}: {uri: string | undefined}) { } onPostReply={onPostReply} hideTopBorder={index === 0 && !item.ctx.isParentLoading} + anchorPostSource={anchorPostSource} /> </View> ) @@ -586,7 +606,7 @@ export function PostThread({uri}: {uri: string | undefined}) { /> </ScrollProvider> {isMobile && canReply && hasSession && ( - <MobileComposePrompt onPressReply={onPressReply} /> + <MobileComposePrompt onPressReply={onReplyToAnchor} /> )} </> ) diff --git a/src/view/com/post-thread/PostThreadItem.tsx b/src/view/com/post-thread/PostThreadItem.tsx index 8b39072ba..576b195a0 100644 --- a/src/view/com/post-thread/PostThreadItem.tsx +++ b/src/view/com/post-thread/PostThreadItem.tsx @@ -40,7 +40,7 @@ import {useLanguagePrefs} from '#/state/preferences' import {type ThreadPost} from '#/state/queries/post-thread' import {useSession} from '#/state/session' import {useMergedThreadgateHiddenReplies} from '#/state/threadgate-hidden-replies' -import {useUnstablePostSource} from '#/state/unstable-post-source' +import {type PostSource} from '#/state/unstable-post-source' import {PostThreadFollowBtn} from '#/view/com/post-thread/PostThreadFollowBtn' import {ErrorMessage} from '#/view/com/util/error/ErrorMessage' import {Link, TextLink} from '#/view/com/util/Link' @@ -87,6 +87,7 @@ export function PostThreadItem({ onPostReply, hideTopBorder, threadgateRecord, + anchorPostSource, }: { post: AppBskyFeedDefs.PostView record: AppBskyFeedPost.Record @@ -104,6 +105,7 @@ export function PostThreadItem({ onPostReply: (postUri: string | undefined) => void hideTopBorder?: boolean threadgateRecord?: AppBskyFeedThreadgate.Record + anchorPostSource?: PostSource }) { const postShadowed = usePostShadow(post) const richText = useMemo( @@ -139,6 +141,7 @@ export function PostThreadItem({ onPostReply={onPostReply} hideTopBorder={hideTopBorder} threadgateRecord={threadgateRecord} + anchorPostSource={anchorPostSource} /> ) } @@ -184,6 +187,7 @@ let PostThreadItemLoaded = ({ onPostReply, hideTopBorder, threadgateRecord, + anchorPostSource, }: { post: Shadow<AppBskyFeedDefs.PostView> record: AppBskyFeedPost.Record @@ -202,10 +206,10 @@ let PostThreadItemLoaded = ({ onPostReply: (postUri: string | undefined) => void hideTopBorder?: boolean threadgateRecord?: AppBskyFeedThreadgate.Record + anchorPostSource?: PostSource }): React.ReactNode => { const {currentAccount, hasSession} = useSession() - const source = useUnstablePostSource(post.uri) - const feedFeedback = useFeedFeedback(source?.feed, hasSession) + const feedFeedback = useFeedFeedback(anchorPostSource?.feed, hasSession) const t = useTheme() const pal = usePalette('default') @@ -276,12 +280,12 @@ let PostThreadItemLoaded = ({ ) const onPressReply = () => { - if (source) { + if (anchorPostSource && isHighlightedPost) { feedFeedback.sendInteraction({ item: post.uri, event: 'app.bsky.feed.defs#interactionReply', - feedContext: source.post.feedContext, - reqId: source.post.reqId, + feedContext: anchorPostSource.post.feedContext, + reqId: anchorPostSource.post.reqId, }) } openComposer({ @@ -298,23 +302,23 @@ let PostThreadItemLoaded = ({ } const onOpenAuthor = () => { - if (source) { + if (anchorPostSource) { feedFeedback.sendInteraction({ item: post.uri, event: 'app.bsky.feed.defs#clickthroughAuthor', - feedContext: source.post.feedContext, - reqId: source.post.reqId, + feedContext: anchorPostSource.post.feedContext, + reqId: anchorPostSource.post.reqId, }) } } const onOpenEmbed = () => { - if (source) { + if (anchorPostSource) { feedFeedback.sendInteraction({ item: post.uri, event: 'app.bsky.feed.defs#clickthroughEmbed', - feedContext: source.post.feedContext, - reqId: source.post.reqId, + feedContext: anchorPostSource.post.feedContext, + reqId: anchorPostSource.post.reqId, }) } } @@ -325,7 +329,7 @@ let PostThreadItemLoaded = ({ const {isActive: live} = useActorStatus(post.author) - const reason = source?.post.reason + const reason = anchorPostSource?.post.reason const viaRepost = useMemo(() => { if (AppBskyFeedDefs.isReasonRepost(reason) && reason.uri && reason.cid) { return { @@ -550,8 +554,8 @@ let PostThreadItemLoaded = ({ onPostReply={onPostReply} logContext="PostThreadItem" threadgateRecord={threadgateRecord} - feedContext={source?.post?.feedContext} - reqId={source?.post?.reqId} + feedContext={anchorPostSource?.post?.feedContext} + reqId={anchorPostSource?.post?.reqId} viaRepost={viaRepost} /> </FeedFeedbackProvider> |