feat(plugins/error-boundary): improve ErrorBoundary screen
This commit is contained in:
parent
30499d543d
commit
e47ba711f4
1 changed files with 33 additions and 14 deletions
|
|
@ -1,16 +1,19 @@
|
||||||
|
import { getAssetIdByName } from '@revenge-mod/assets'
|
||||||
import { styles } from '@revenge-mod/components/_'
|
import { styles } from '@revenge-mod/components/_'
|
||||||
import { Tokens } from '@revenge-mod/discord/common/tokens'
|
import { Tokens } from '@revenge-mod/discord/common/tokens'
|
||||||
import { Design } from '@revenge-mod/discord/design'
|
import { Design } from '@revenge-mod/discord/design'
|
||||||
import { ClientInfoModule } from '@revenge-mod/discord/native'
|
import { ClientInfoModule } from '@revenge-mod/discord/native'
|
||||||
import { Clipboard } from '@revenge-mod/externals/react-native-clipboard'
|
import { Clipboard } from '@revenge-mod/externals/react-native-clipboard'
|
||||||
import { ReactNativeSafeAreaContext } from '@revenge-mod/externals/react-native-safe-area-context'
|
import { ReactNativeSafeAreaContext } from '@revenge-mod/externals/react-native-safe-area-context'
|
||||||
|
import { reloadApp } from '@revenge-mod/modules/native/app'
|
||||||
|
import { requestNextBootDefaultsOnly } from '@revenge-mod/plugins/_'
|
||||||
import { getErrorStack } from '@revenge-mod/utils/error'
|
import { getErrorStack } from '@revenge-mod/utils/error'
|
||||||
import { ScrollView, StyleSheet, View } from 'react-native'
|
import { ScrollView, StyleSheet, View } from 'react-native'
|
||||||
import { FullVersion } from '~/constants'
|
import { FullVersion } from '~/constants'
|
||||||
import { getRNVersion } from '~plugins/start/settings/definitions/shared'
|
import { getRNVersion } from '~plugins/start/settings/definitions/shared'
|
||||||
import type { ComponentProps } from 'react'
|
import type { ComponentProps } from 'react'
|
||||||
|
|
||||||
const { createStyles, Button, Card, Stack, Text } = Design
|
const { createStyles, Button, Card, IconButton, Stack, Text } = Design
|
||||||
|
|
||||||
const useErrorBoundaryStyles = createStyles({
|
const useErrorBoundaryStyles = createStyles({
|
||||||
view: {
|
view: {
|
||||||
|
|
@ -35,6 +38,9 @@ const additionalStyles = StyleSheet.create({
|
||||||
fontWeight: 'bold',
|
fontWeight: 'bold',
|
||||||
marginBottom: 8,
|
marginBottom: 8,
|
||||||
},
|
},
|
||||||
|
actions: {
|
||||||
|
flexShrink: 0,
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
interface RenderError extends Error {
|
interface RenderError extends Error {
|
||||||
|
|
@ -118,19 +124,31 @@ export default function ErrorBoundaryScreen({
|
||||||
</Text>
|
</Text>
|
||||||
</LabeledCard>
|
</LabeledCard>
|
||||||
)}
|
)}
|
||||||
<Stack direction="horizontal" spacing={16}>
|
<Stack spacing={8} style={additionalStyles.actions}>
|
||||||
<Button
|
<Button
|
||||||
style={styles.flex}
|
icon={getAssetIdByName('ShieldIcon')}
|
||||||
variant="secondary"
|
text="Enter Recovery Mode"
|
||||||
text="Retry Render"
|
onPress={() => {
|
||||||
onPress={rerender}
|
requestNextBootDefaultsOnly()
|
||||||
/>
|
reloadApp()
|
||||||
<Button
|
}}
|
||||||
style={styles.flex}
|
|
||||||
variant="destructive"
|
|
||||||
text="Reload"
|
|
||||||
onPress={reload}
|
|
||||||
/>
|
/>
|
||||||
|
<Stack direction="horizontal" spacing={16}>
|
||||||
|
<Button
|
||||||
|
icon={getAssetIdByName('SendMessageIcon')}
|
||||||
|
style={styles.flex}
|
||||||
|
variant="secondary"
|
||||||
|
text="Retry Render"
|
||||||
|
onPress={rerender}
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
icon={getAssetIdByName('RetryIcon')}
|
||||||
|
style={styles.flex}
|
||||||
|
variant="destructive"
|
||||||
|
text="Reload"
|
||||||
|
onPress={reload}
|
||||||
|
/>
|
||||||
|
</Stack>
|
||||||
</Stack>
|
</Stack>
|
||||||
</ReactNativeSafeAreaContext.SafeAreaView>
|
</ReactNativeSafeAreaContext.SafeAreaView>
|
||||||
)
|
)
|
||||||
|
|
@ -158,10 +176,11 @@ export function LabeledCard(props: LabeledCardProps) {
|
||||||
{props.label}
|
{props.label}
|
||||||
</Text>
|
</Text>
|
||||||
{props.rawContent && (
|
{props.rawContent && (
|
||||||
<Button
|
<IconButton
|
||||||
|
icon={getAssetIdByName('CopyIcon')!}
|
||||||
|
accessibilityHint="Copy"
|
||||||
variant="secondary"
|
variant="secondary"
|
||||||
size="sm"
|
size="sm"
|
||||||
text="Copy"
|
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
Clipboard.setString(props.rawContent as string)
|
Clipboard.setString(props.rawContent as string)
|
||||||
}}
|
}}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue