From 4615056f1757ee3102b89fc3642e65aa6054ba92 Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Mon, 5 Aug 2024 15:08:01 -0500 Subject: [PATCH] Fix threadgate record load --- src/view/com/post-thread/PostThread.tsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/view/com/post-thread/PostThread.tsx b/src/view/com/post-thread/PostThread.tsx index 9518f1f7cf..b8481a10e9 100644 --- a/src/view/com/post-thread/PostThread.tsx +++ b/src/view/com/post-thread/PostThread.tsx @@ -1,7 +1,11 @@ import React, {useEffect, useRef} from 'react' import {useWindowDimensions, View} from 'react-native' import {runOnJS} from 'react-native-reanimated' -import {AppBskyFeedDefs, AppBskyFeedThreadgate} from '@atproto/api' +import { + AppBskyFeedDefs, + AppBskyFeedPost, + AppBskyFeedThreadgate, +} from '@atproto/api' import {msg, Trans} from '@lingui/macro' import {useLingui} from '@lingui/react' @@ -117,9 +121,13 @@ export function PostThread({ ) const rootPost = thread?.type === 'post' ? thread.post : undefined const rootPostRecord = thread?.type === 'post' ? thread.record : undefined + const replyRef = + rootPost && AppBskyFeedPost.isRecord(rootPost.record) + ? rootPost.record.reply + : undefined const {data: threadgateRecord} = useThreadgateRecordQuery({ - postUri: rootPost?.record?.reply?.root?.uri, + postUri: replyRef ? replyRef.root.uri : rootPost?.uri, initialData: rootPost?.threadgate?.record as AppBskyFeedThreadgate.Record, })