Skip to content

[No QA] Fixed generic error page when user is not authenticated #61831

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions src/pages/ErrorPage/GenericErrorPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,22 @@ import ImageSVG from '@components/ImageSVG';
import SafeAreaConsumer from '@components/SafeAreaConsumer';
import Text from '@components/Text';
import TextLink from '@components/TextLink';
import useIsAuthenticated from '@hooks/useIsAuthenticated';
import useLocalize from '@hooks/useLocalize';
import usePageRefresh from '@hooks/usePageRefresh';
import useStyleUtils from '@hooks/useStyleUtils';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import variables from '@styles/variables';
import * as Session from '@userActions/Session';
import {signOutAndRedirectToSignIn} from '@userActions/Session';
import CONST from '@src/CONST';
import ErrorBodyText from './ErrorBodyText';

function GenericErrorPage({error}: {error?: Error}) {
const theme = useTheme();
const styles = useThemeStyles();
const StyleUtils = useStyleUtils();
const isAuthenticated = useIsAuthenticated();
const {translate} = useLocalize();
const isChunkLoadError = error?.name === CONST.CHUNK_LOAD_ERROR || /Loading chunk [\d]+ failed/.test(error?.message ?? '');
const refreshPage = usePageRefresh();
Expand Down Expand Up @@ -63,13 +65,15 @@ function GenericErrorPage({error}: {error?: Error}) {
style={styles.mr3}
onPress={() => refreshPage(isChunkLoadError)}
/>
<Button
text={translate('initialSettingsPage.signOut')}
onPress={() => {
Session.signOutAndRedirectToSignIn();
refreshPage();
}}
/>
{isAuthenticated && (
<Button
text={translate('initialSettingsPage.signOut')}
onPress={() => {
signOutAndRedirectToSignIn();
refreshPage();
}}
/>
)}
</View>
</View>
</View>
Expand Down