Fix to error screen and postthread loading state (#540)
* Fix loading state on postthread * Improve error screen rendering * Dark mode exclamation in error screen * Fix lintzio/stable
parent
8f3915e0a5
commit
ae895155fd
|
@ -130,10 +130,16 @@ export const PostThread = observer(function PostThread({
|
||||||
|
|
||||||
// loading
|
// loading
|
||||||
// =
|
// =
|
||||||
if ((view.isLoading && !view.isRefreshing) || view.params.uri !== uri) {
|
if (
|
||||||
|
!view.hasLoaded ||
|
||||||
|
(view.isLoading && !view.isRefreshing) ||
|
||||||
|
view.params.uri !== uri
|
||||||
|
) {
|
||||||
return (
|
return (
|
||||||
<CenteredView>
|
<CenteredView>
|
||||||
<ActivityIndicator />
|
<View style={s.p20}>
|
||||||
|
<ActivityIndicator size="large" />
|
||||||
|
</View>
|
||||||
</CenteredView>
|
</CenteredView>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import {StyleSheet, TouchableOpacity, View} from 'react-native'
|
import {StyleSheet, View} from 'react-native'
|
||||||
import {
|
import {
|
||||||
FontAwesomeIcon,
|
FontAwesomeIcon,
|
||||||
FontAwesomeIconStyle,
|
FontAwesomeIconStyle,
|
||||||
} from '@fortawesome/react-native-fontawesome'
|
} from '@fortawesome/react-native-fontawesome'
|
||||||
import {Text} from '../text/Text'
|
import {Text} from '../text/Text'
|
||||||
import {colors} from 'lib/styles'
|
|
||||||
import {useTheme} from 'lib/ThemeContext'
|
import {useTheme} from 'lib/ThemeContext'
|
||||||
import {usePalette} from 'lib/hooks/usePalette'
|
import {usePalette} from 'lib/hooks/usePalette'
|
||||||
|
import {Button} from '../forms/Button'
|
||||||
import {CenteredView} from '../Views'
|
import {CenteredView} from '../Views'
|
||||||
|
|
||||||
export function ErrorScreen({
|
export function ErrorScreen({
|
||||||
|
@ -24,18 +24,18 @@ export function ErrorScreen({
|
||||||
testID?: string
|
testID?: string
|
||||||
}) {
|
}) {
|
||||||
const theme = useTheme()
|
const theme = useTheme()
|
||||||
const pal = usePalette('error')
|
const pal = usePalette('default')
|
||||||
return (
|
return (
|
||||||
<CenteredView testID={testID} style={[styles.outer, pal.view]}>
|
<CenteredView testID={testID} style={[styles.outer, pal.view]}>
|
||||||
<View style={styles.errorIconContainer}>
|
<View style={styles.errorIconContainer}>
|
||||||
<View
|
<View
|
||||||
style={[
|
style={[
|
||||||
styles.errorIcon,
|
styles.errorIcon,
|
||||||
{backgroundColor: theme.palette.error.icon},
|
{backgroundColor: theme.palette.inverted.background},
|
||||||
]}>
|
]}>
|
||||||
<FontAwesomeIcon
|
<FontAwesomeIcon
|
||||||
icon="exclamation"
|
icon="exclamation"
|
||||||
style={{color: colors.white}}
|
style={pal.textInverted}
|
||||||
size={24}
|
size={24}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
|
@ -43,34 +43,30 @@ export function ErrorScreen({
|
||||||
<Text type="title-lg" style={[styles.title, pal.text]}>
|
<Text type="title-lg" style={[styles.title, pal.text]}>
|
||||||
{title}
|
{title}
|
||||||
</Text>
|
</Text>
|
||||||
<Text style={[styles.message, pal.textLight]}>{message}</Text>
|
<Text style={[styles.message, pal.text]}>{message}</Text>
|
||||||
{details && (
|
{details && (
|
||||||
<Text
|
<Text
|
||||||
testID={`${testID}-details`}
|
testID={`${testID}-details`}
|
||||||
type="sm"
|
style={[styles.details, pal.text, pal.viewLight]}>
|
||||||
style={[
|
|
||||||
styles.details,
|
|
||||||
pal.textInverted,
|
|
||||||
{backgroundColor: theme.palette.default.background},
|
|
||||||
]}>
|
|
||||||
{details}
|
{details}
|
||||||
</Text>
|
</Text>
|
||||||
)}
|
)}
|
||||||
{onPressTryAgain && (
|
{onPressTryAgain && (
|
||||||
<View style={styles.btnContainer}>
|
<View style={styles.btnContainer}>
|
||||||
<TouchableOpacity
|
<Button
|
||||||
testID="errorScreenTryAgainButton"
|
testID="errorScreenTryAgainButton"
|
||||||
style={[styles.btn, {backgroundColor: theme.palette.error.icon}]}
|
type="default"
|
||||||
|
style={[styles.btn]}
|
||||||
onPress={onPressTryAgain}>
|
onPress={onPressTryAgain}>
|
||||||
<FontAwesomeIcon
|
<FontAwesomeIcon
|
||||||
icon="arrows-rotate"
|
icon="arrows-rotate"
|
||||||
style={pal.text as FontAwesomeIconStyle}
|
style={pal.link as FontAwesomeIconStyle}
|
||||||
size={16}
|
size={16}
|
||||||
/>
|
/>
|
||||||
<Text type="button" style={[styles.btnText, pal.text]}>
|
<Text type="button" style={[styles.btnText, pal.link]}>
|
||||||
Try again
|
Try again
|
||||||
</Text>
|
</Text>
|
||||||
</TouchableOpacity>
|
</Button>
|
||||||
</View>
|
</View>
|
||||||
)}
|
)}
|
||||||
</CenteredView>
|
</CenteredView>
|
||||||
|
@ -115,11 +111,10 @@ const styles = StyleSheet.create({
|
||||||
marginBottom: 10,
|
marginBottom: 10,
|
||||||
},
|
},
|
||||||
errorIcon: {
|
errorIcon: {
|
||||||
borderRadius: 30,
|
borderRadius: 25,
|
||||||
width: 50,
|
width: 50,
|
||||||
height: 50,
|
height: 50,
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
marginRight: 5,
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
|
@ -145,8 +145,7 @@ export const ProfileScreen = withAuthRequired(
|
||||||
<ErrorScreen
|
<ErrorScreen
|
||||||
testID="profileErrorScreen"
|
testID="profileErrorScreen"
|
||||||
title="Failed to load profile"
|
title="Failed to load profile"
|
||||||
message={`There was an issue when attempting to load ${route.params.name}`}
|
message={uiState.profile.error}
|
||||||
details={uiState.profile.error}
|
|
||||||
onPressTryAgain={onPressTryAgain}
|
onPressTryAgain={onPressTryAgain}
|
||||||
/>
|
/>
|
||||||
) : uiState.profile.hasLoaded ? (
|
) : uiState.profile.hasLoaded ? (
|
||||||
|
|
Loading…
Reference in New Issue