Bluesky app fork with some witchin' additions 💫
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Move onPressReply into child component (#4898)

* Move ComposePrompt to post-thread/

* Move onPressReply into child component

authored by

dan and committed by
GitHub
ae25cb33 85fe95c9

+31 -43
+5 -1
src/view/com/composer/Prompt.tsx src/view/com/post-thread/PostThreadComposePrompt.tsx
··· 10 10 import {Text} from '../util/text/Text' 11 11 import {UserAvatar} from '../util/UserAvatar' 12 12 13 - export function ComposePrompt({onPressCompose}: {onPressCompose: () => void}) { 13 + export function PostThreadComposePrompt({ 14 + onPressCompose, 15 + }: { 16 + onPressCompose: () => void 17 + }) { 14 18 const {currentAccount} = useSession() 15 19 const {data: profile} = useProfileQuery({did: currentAccount?.did}) 16 20 const pal = usePalette('default')
+24 -10
src/view/com/post-thread/PostThread.tsx
··· 24 24 } from '#/state/queries/post-thread' 25 25 import {usePreferencesQuery} from '#/state/queries/preferences' 26 26 import {useSession} from '#/state/session' 27 + import {useComposerControls} from '#/state/shell' 27 28 import {useInitialNumToRender} from 'lib/hooks/useInitialNumToRender' 28 29 import {useMinimalShellFabTransform} from 'lib/hooks/useMinimalShellTransform' 29 30 import {useSetTitle} from 'lib/hooks/useSetTitle' ··· 34 35 import {atoms as a, useTheme} from '#/alf' 35 36 import {ListFooter, ListMaybePlaceholder} from '#/components/Lists' 36 37 import {Text} from '#/components/Typography' 37 - import {ComposePrompt} from '../composer/Prompt' 38 38 import {List, ListMethods} from '../util/List' 39 39 import {ViewHeader} from '../util/ViewHeader' 40 + import {PostThreadComposePrompt} from './PostThreadComposePrompt' 40 41 import {PostThreadItem} from './PostThreadItem' 41 42 import {PostThreadLoadMore} from './PostThreadLoadMore' 42 43 import {PostThreadShowHiddenReplies} from './PostThreadShowHiddenReplies' ··· 84 85 return item._reactKey 85 86 } 86 87 87 - export function PostThread({ 88 - uri, 89 - onPressReply, 90 - }: { 91 - uri: string | undefined 92 - onPressReply: () => unknown 93 - }) { 88 + export function PostThread({uri}: {uri: string | undefined}) { 94 89 const {hasSession, currentAccount} = useSession() 95 90 const {_} = useLingui() 96 91 const t = useTheme() ··· 307 302 setMaxReplies(prev => prev + 50) 308 303 }, [isFetching, maxReplies, posts.length]) 309 304 305 + const {openComposer} = useComposerControls() 306 + const onPressReply = React.useCallback(() => { 307 + if (thread?.type !== 'post') { 308 + return 309 + } 310 + openComposer({ 311 + replyTo: { 312 + uri: thread.post.uri, 313 + cid: thread.post.cid, 314 + text: thread.record.text, 315 + author: thread.post.author, 316 + embed: thread.post.embed, 317 + }, 318 + onPost: () => refetch(), 319 + }) 320 + }, [openComposer, thread, refetch]) 321 + 310 322 const canReply = !error && rootPost && !rootPost.viewer?.replyDisabled 311 323 const hasParents = 312 324 skeleton?.highlightedPost?.type === 'post' && ··· 319 331 if (item === REPLY_PROMPT && hasSession) { 320 332 return ( 321 333 <View> 322 - {!isMobile && <ComposePrompt onPressCompose={onPressReply} />} 334 + {!isMobile && ( 335 + <PostThreadComposePrompt onPressCompose={onPressReply} /> 336 + )} 323 337 </View> 324 338 ) 325 339 } else if (item === SHOW_HIDDEN_REPLIES || item === SHOW_MUTED_REPLIES) { ··· 487 501 bottom: clamp(safeAreaInsets.bottom, 15, 30), 488 502 }, 489 503 ]}> 490 - <ComposePrompt onPressCompose={onPressReply} /> 504 + <PostThreadComposePrompt onPressCompose={onPressReply} /> 491 505 </Animated.View> 492 506 ) 493 507 }
+2 -32
src/view/screens/PostThread.tsx
··· 1 1 import React from 'react' 2 2 import {View} from 'react-native' 3 3 import {useFocusEffect} from '@react-navigation/native' 4 - import {useQueryClient} from '@tanstack/react-query' 5 4 6 - import { 7 - RQKEY as POST_THREAD_RQKEY, 8 - ThreadNode, 9 - } from '#/state/queries/post-thread' 10 5 import {useSetMinimalShellMode} from '#/state/shell' 11 - import {useComposerControls} from '#/state/shell/composer' 12 6 import {CommonNavigatorParams, NativeStackScreenProps} from 'lib/routes/types' 13 7 import {makeRecordUri} from 'lib/strings/url-helpers' 14 8 import {s} from 'lib/styles' ··· 16 10 17 11 type Props = NativeStackScreenProps<CommonNavigatorParams, 'PostThread'> 18 12 export function PostThreadScreen({route}: Props) { 19 - const queryClient = useQueryClient() 20 13 const setMinimalShellMode = useSetMinimalShellMode() 21 - const {openComposer} = useComposerControls() 14 + 22 15 const {name, rkey} = route.params 23 16 const uri = makeRecordUri(name, 'app.bsky.feed.post', rkey) 24 17 ··· 28 21 }, [setMinimalShellMode]), 29 22 ) 30 23 31 - const onPressReply = React.useCallback(() => { 32 - if (!uri) { 33 - return 34 - } 35 - const thread = queryClient.getQueryData<ThreadNode>(POST_THREAD_RQKEY(uri)) 36 - if (thread?.type !== 'post') { 37 - return 38 - } 39 - openComposer({ 40 - replyTo: { 41 - uri: thread.post.uri, 42 - cid: thread.post.cid, 43 - text: thread.record.text, 44 - author: thread.post.author, 45 - embed: thread.post.embed, 46 - }, 47 - onPost: () => 48 - queryClient.invalidateQueries({ 49 - queryKey: POST_THREAD_RQKEY(uri), 50 - }), 51 - }) 52 - }, [openComposer, queryClient, uri]) 53 - 54 24 return ( 55 25 <View style={s.hContentRegion}> 56 26 <View style={s.flex1}> 57 - <PostThreadComponent uri={uri} onPressReply={onPressReply} /> 27 + <PostThreadComponent uri={uri} /> 58 28 </View> 59 29 </View> 60 30 )