From 468d6d0f41713c39d3cff811125392dccb83fc0c Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Wed, 11 Jun 2025 18:36:20 -0500 Subject: [PATCH] WIP --- src/screens/PostThread/index.tsx | 32 +++++++++++++++++++++--- src/state/queries/usePostThread/types.ts | 4 +++ 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/src/screens/PostThread/index.tsx b/src/screens/PostThread/index.tsx index 1471c9fd5b..6cbd2b6510 100644 --- a/src/screens/PostThread/index.tsx +++ b/src/screens/PostThread/index.tsx @@ -41,6 +41,7 @@ import {ListFooter} from '#/components/Lists' const PARENT_CHUNK_SIZE = 5 const CHILDREN_CHUNK_SIZE = 50 +const MIN_FOOTER_HEIGHT = 140 export function PostThread({uri}: {uri: string}) { const {gtMobile} = useBreakpoints() @@ -117,6 +118,8 @@ export function PostThread({uri}: {uri: string}) { const listRef = useRef(null) const anchorRef = useRef(null) const headerRef = useRef(null) + const bookendRef = useRef(null) + const [bookendOffset, setBookendOffset] = useState(0) /* * On a cold load, parents are not prepended until the anchor post has @@ -203,6 +206,13 @@ export function PostThread({uri}: {uri: string}) { * do not affect scroll. */ if (!deferParents || isRoot) shouldHandleScroll.current = false + + bookendRef.current?.measure( + (_x, _y, _width, _height, _pageX, pageY) => { + console.log('Bookend offset:', pageY) + setBookendOffset(pageY) + }, + ) } }) @@ -349,7 +359,7 @@ export function PostThread({uri}: {uri: string}) { } } - return results + return results.concat({type: 'bookend', key: 'bookend'}) }, [thread, deferParents, maxParentCount, maxChildrenCount]) const isTombstoneView = useMemo(() => { @@ -469,6 +479,22 @@ export function PostThread({uri}: {uri: string}) { } else if (item.item === 'replyComposer') { return } + } else if (item.type === 'bookend') { + return ( + { + return + bookendRef.current?.measure( + (_x, _y, _width, _height, _pageX, pageY) => { + console.log('Bookend offset:', pageY) + setBookendOffset(pageY) + }, + ) + }} + /> + ) } return null }, @@ -482,8 +508,8 @@ export function PostThread({uri}: {uri: string}) { ) const footerHeight = useMemo( - () => Math.max(180, windowHeight - 200 - thread.state.replyCount * 100), - [windowHeight, thread.state.replyCount], + () => Math.max(MIN_FOOTER_HEIGHT, windowHeight - bookendOffset), + [bookendOffset], ) return ( diff --git a/src/state/queries/usePostThread/types.ts b/src/state/queries/usePostThread/types.ts index 2f370b0ab7..fcd1fa7e1d 100644 --- a/src/state/queries/usePostThread/types.ts +++ b/src/state/queries/usePostThread/types.ts @@ -120,6 +120,10 @@ export type ThreadItem = key: string item: 'anchor' | 'reply' | 'replyComposer' } + | { + type: 'bookend' + key: 'bookend' + } /** * Metadata collected while traversing the raw data from the thread response.