Skip to content

Commit 805e233

Browse files
authored
Merge pull request #61831 from shubham1206agra/fix-signout-generic-error
[No QA] Fixed generic error page when user is not authenticated
2 parents a9ff331 + 187766a commit 805e233

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/pages/ErrorPage/GenericErrorPage.tsx

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,22 @@ import ImageSVG from '@components/ImageSVG';
88
import SafeAreaConsumer from '@components/SafeAreaConsumer';
99
import Text from '@components/Text';
1010
import TextLink from '@components/TextLink';
11+
import useIsAuthenticated from '@hooks/useIsAuthenticated';
1112
import useLocalize from '@hooks/useLocalize';
1213
import usePageRefresh from '@hooks/usePageRefresh';
1314
import useStyleUtils from '@hooks/useStyleUtils';
1415
import useTheme from '@hooks/useTheme';
1516
import useThemeStyles from '@hooks/useThemeStyles';
1617
import variables from '@styles/variables';
17-
import * as Session from '@userActions/Session';
18+
import {signOutAndRedirectToSignIn} from '@userActions/Session';
1819
import CONST from '@src/CONST';
1920
import ErrorBodyText from './ErrorBodyText';
2021

2122
function GenericErrorPage({error}: {error?: Error}) {
2223
const theme = useTheme();
2324
const styles = useThemeStyles();
2425
const StyleUtils = useStyleUtils();
26+
const isAuthenticated = useIsAuthenticated();
2527
const {translate} = useLocalize();
2628
const isChunkLoadError = error?.name === CONST.CHUNK_LOAD_ERROR || /Loading chunk [\d]+ failed/.test(error?.message ?? '');
2729
const refreshPage = usePageRefresh();
@@ -63,13 +65,15 @@ function GenericErrorPage({error}: {error?: Error}) {
6365
style={styles.mr3}
6466
onPress={() => refreshPage(isChunkLoadError)}
6567
/>
66-
<Button
67-
text={translate('initialSettingsPage.signOut')}
68-
onPress={() => {
69-
Session.signOutAndRedirectToSignIn();
70-
refreshPage();
71-
}}
72-
/>
68+
{isAuthenticated && (
69+
<Button
70+
text={translate('initialSettingsPage.signOut')}
71+
onPress={() => {
72+
signOutAndRedirectToSignIn();
73+
refreshPage();
74+
}}
75+
/>
76+
)}
7377
</View>
7478
</View>
7579
</View>

0 commit comments

Comments
 (0)