Skip to content

Commit

Permalink
Handle post-thread uri resolution errors
Browse files Browse the repository at this point in the history
  • Loading branch information
pfrazee committed Nov 9, 2023
1 parent 70e530d commit 33d10c0
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/view/screens/PostThread.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import {useWebMediaQueries} from 'lib/hooks/useWebMediaQueries'
import {useMinimalShellMode} from 'lib/hooks/useMinimalShellMode'
import {useSetMinimalShellMode} from '#/state/shell'
import {useResolveUriQuery} from '#/state/queries/resolve-uri'
import {ErrorMessage} from '../com/util/error/ErrorMessage'
import {CenteredView} from '../com/util/Views'

type Props = NativeStackScreenProps<CommonNavigatorParams, 'PostThread'>
export const PostThreadScreen = withAuthRequired(
Expand All @@ -34,7 +36,7 @@ export const PostThreadScreen = withAuthRequired(
const {name, rkey} = route.params
const {isMobile} = useWebMediaQueries()
const uri = makeRecordUri(name, 'app.bsky.feed.post', rkey)
const {data: resolvedUri} = useResolveUriQuery(uri)
const {data: resolvedUri, error: uriError} = useResolveUriQuery(uri)

useFocusEffect(
React.useCallback(() => {
Expand Down Expand Up @@ -74,11 +76,17 @@ export const PostThreadScreen = withAuthRequired(
<View style={s.hContentRegion}>
{isMobile && <ViewHeader title="Post" />}
<View style={s.flex1}>
<PostThreadComponent
uri={resolvedUri}
onPressReply={onPressReply}
treeView={!!store.preferences.thread.lab_treeViewEnabled}
/>
{uriError ? (
<CenteredView>
<ErrorMessage message={String(uriError)} />
</CenteredView>
) : (
<PostThreadComponent
uri={resolvedUri}
onPressReply={onPressReply}
treeView={!!store.preferences.thread.lab_treeViewEnabled}
/>
)}
</View>
{isMobile && (
<Animated.View
Expand Down

0 comments on commit 33d10c0

Please sign in to comment.