diff --git a/src/view/screens/PostThread.tsx b/src/view/screens/PostThread.tsx index 652644aa5c..b8debaa929 100644 --- a/src/view/screens/PostThread.tsx +++ b/src/view/screens/PostThread.tsx @@ -212,10 +212,30 @@ export function Inner({uri}: {uri: string | undefined}) { } }) + /* + * On native, any time we navigate to a new post/reply (even if the data is + * cached), we skip rendering parents so that the anchor post is the first + * item in the list. That way, + * `maintainVisibleContentPosition={{minIndexForVisible: 0}}` will pin the + * anchor post to the top of the screen, and on the next render, we'll + * include parents. + * + * On the web this is not necessary because we can synchronously adjust the + * scroll in onContentSizeChange instead. + */ + const [deferParents, setDeferParents] = useState(isNative) + const items = useMemo(() => { + return (data?.items ?? []).filter(item => { + return !('depth' in item) || item.depth >= 0 || !deferParents + }) + }, [data, deferParents]) + const renderItem = ({item, index}: {item: Slice; index: number}) => { if (item.type === 'threadPost') { return ( - + setDeferParents(false) : undefined}>