Implement validation and proper type detection
This commit is contained in:
parent
1acef14a1c
commit
b9b0965000
7 changed files with 114 additions and 30 deletions
|
@ -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]}>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue