Improve error messages
This commit is contained in:
parent
6e93301542
commit
fb3a43c216
15 changed files with 156 additions and 32 deletions
|
@ -1,18 +1,12 @@
|
|||
import React, {useState, useEffect} from 'react'
|
||||
import {observer} from 'mobx-react-lite'
|
||||
import {
|
||||
ActivityIndicator,
|
||||
FlatList,
|
||||
Image,
|
||||
StyleSheet,
|
||||
Text,
|
||||
View,
|
||||
} from 'react-native'
|
||||
import {ActivityIndicator, FlatList, StyleSheet, Text, View} from 'react-native'
|
||||
import {
|
||||
RepostedByViewModel,
|
||||
RepostedByViewItemModel,
|
||||
} from '../../../state/models/reposted-by-view'
|
||||
import {UserAvatar} from '../util/UserAvatar'
|
||||
import {ErrorMessage} from '../util/ErrorMessage'
|
||||
import {Link} from '../util/Link'
|
||||
import {useStores} from '../../../state'
|
||||
import {s, colors} from '../../lib/styles'
|
||||
|
@ -38,6 +32,10 @@ export const PostRepostedBy = observer(function PostRepostedBy({
|
|||
.catch(err => console.error('Failed to fetch reposted by', err))
|
||||
}, [uri, view?.params.uri, store])
|
||||
|
||||
const onRefresh = () => {
|
||||
view?.refresh()
|
||||
}
|
||||
|
||||
// loading
|
||||
// =
|
||||
if (
|
||||
|
@ -57,7 +55,12 @@ export const PostRepostedBy = observer(function PostRepostedBy({
|
|||
if (view.hasError) {
|
||||
return (
|
||||
<View>
|
||||
<Text>{view.error}</Text>
|
||||
<ErrorMessage
|
||||
dark
|
||||
message={view.error}
|
||||
style={{margin: 6}}
|
||||
onPressTryAgain={onRefresh}
|
||||
/>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import {
|
|||
import {useStores} from '../../../state'
|
||||
import {SharePostModel} from '../../../state/models/shell-ui'
|
||||
import {PostThreadItem} from './PostThreadItem'
|
||||
import {ErrorMessage} from '../util/ErrorMessage'
|
||||
|
||||
export const PostThread = observer(function PostThread({uri}: {uri: string}) {
|
||||
const store = useStores()
|
||||
|
@ -50,7 +51,12 @@ export const PostThread = observer(function PostThread({uri}: {uri: string}) {
|
|||
if (view.hasError) {
|
||||
return (
|
||||
<View>
|
||||
<Text>{view.error}</Text>
|
||||
<ErrorMessage
|
||||
dark
|
||||
message={view.error}
|
||||
style={{margin: 6}}
|
||||
onPressTryAgain={onRefresh}
|
||||
/>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import {
|
|||
VotesViewItemModel,
|
||||
} from '../../../state/models/votes-view'
|
||||
import {Link} from '../util/Link'
|
||||
import {ErrorMessage} from '../util/ErrorMessage'
|
||||
import {UserAvatar} from '../util/UserAvatar'
|
||||
import {useStores} from '../../../state'
|
||||
import {s, colors} from '../../lib/styles'
|
||||
|
@ -31,6 +32,10 @@ export const PostVotedBy = observer(function PostVotedBy({
|
|||
newView.setup().catch(err => console.error('Failed to fetch voted by', err))
|
||||
}, [uri, view?.params.uri, store])
|
||||
|
||||
const onRefresh = () => {
|
||||
view?.refresh()
|
||||
}
|
||||
|
||||
// loading
|
||||
// =
|
||||
if (
|
||||
|
@ -50,7 +55,12 @@ export const PostVotedBy = observer(function PostVotedBy({
|
|||
if (view.hasError) {
|
||||
return (
|
||||
<View>
|
||||
<Text>{view.error}</Text>
|
||||
<ErrorMessage
|
||||
dark
|
||||
message={view.error}
|
||||
style={{margin: 6}}
|
||||
onPressTryAgain={onRefresh}
|
||||
/>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue