From b9b096500063a38fdf3858a362858b447103ec07 Mon Sep 17 00:00:00 2001
From: Paul Frazee <pfrazee@gmail.com>
Date: Tue, 3 Jan 2023 13:08:56 -0600
Subject: Implement validation and proper type detection

---
 src/view/com/post-thread/PostThreadItem.tsx | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

(limited to 'src/view/com/post-thread/PostThreadItem.tsx')

diff --git a/src/view/com/post-thread/PostThreadItem.tsx b/src/view/com/post-thread/PostThreadItem.tsx
index e8c23d3a2..e93f77e3c 100644
--- a/src/view/com/post-thread/PostThreadItem.tsx
+++ b/src/view/com/post-thread/PostThreadItem.tsx
@@ -3,7 +3,6 @@ import {observer} from 'mobx-react-lite'
 import {StyleSheet, View} from 'react-native'
 import Clipboard from '@react-native-clipboard/clipboard'
 import {AtUri} from '../../../third-party/uri'
-import {AppBskyFeedPost} from '@atproto/api'
 import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
 import {PostThreadViewPostModel} from '../../../state/models/post-thread-view'
 import {Link} from '../util/Link'
@@ -18,6 +17,7 @@ import {useStores} from '../../../state'
 import {PostMeta} from '../util/PostMeta'
 import {PostEmbeds} from '../util/PostEmbeds'
 import {PostCtrls} from '../util/PostCtrls'
+import {ErrorMessage} from '../util/error/ErrorMessage'
 import {ComposePrompt} from '../composer/Prompt'
 import {usePalette} from '../../lib/hooks/usePalette'
 
@@ -33,7 +33,7 @@ export const PostThreadItem = observer(function PostThreadItem({
   const pal = usePalette('default')
   const store = useStores()
   const [deleted, setDeleted] = useState(false)
-  const record = item.post.record as unknown as AppBskyFeedPost.Record
+  const record = item.postRecord
   const hasEngagement = item.post.upvoteCount || item.post.repostCount
 
   const itemHref = useMemo(() => {
@@ -96,6 +96,10 @@ export const PostThreadItem = observer(function PostThreadItem({
     )
   }
 
+  if (!record) {
+    return <ErrorMessage message="Invalid or unsupported post record" />
+  }
+
   if (deleted) {
     return (
       <View style={[styles.outer, pal.view, s.p20, s.flexRow]}>
-- 
cgit 1.4.1

