Skip to content

Commit 1dd8ce4

Browse files
committed
Revert "Show the offline view only to signed-out users and give it a background"
This reverts commit 81211b8.
1 parent 81211b8 commit 1dd8ce4

4 files changed

Lines changed: 18 additions & 77 deletions

File tree

‎src/pages/ValidateLoginPage/index.tsx‎

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import FullPageOfflineBlockingView from '@components/BlockingViews/FullPageOfflineBlockingView';
22
import FullScreenLoadingIndicator from '@components/FullscreenLoadingIndicator';
33

4-
import useNetwork from '@hooks/useNetwork';
54
import useOnyx from '@hooks/useOnyx';
6-
import useThemeStyles from '@hooks/useThemeStyles';
75

86
import Navigation from '@libs/Navigation/Navigation';
97

@@ -13,7 +11,6 @@ import CONST from '@src/CONST';
1311
import ONYXKEYS from '@src/ONYXKEYS';
1412

1513
import React, {useEffect} from 'react';
16-
import {StyleSheet, View} from 'react-native';
1714

1815
import type ValidateLoginPageProps from './types';
1916

@@ -24,14 +21,11 @@ function ValidateLoginPage({
2421
}: ValidateLoginPageProps) {
2522
const [session] = useOnyx(ONYXKEYS.SESSION);
2623
const [preferredLocale] = useOnyx(ONYXKEYS.NVP_PREFERRED_LOCALE);
27-
const {isOffline} = useNetwork();
28-
const styles = useThemeStyles();
29-
const isSignedIn = !!session?.authToken && session?.authTokenType !== CONST.AUTH_TOKEN_TYPES.ANONYMOUS;
3024

3125
useEffect(() => {
3226
// Wait till navigation becomes available
3327
Navigation.isNavigationReady().then(() => {
34-
if (isSignedIn) {
28+
if (session?.authToken && session?.authTokenType !== CONST.AUTH_TOKEN_TYPES.ANONYMOUS) {
3529
// If already signed in, do not show the validate code if not on web,
3630
// because we don't want to block the user with the interstitial page.
3731
if (exitTo) {
@@ -56,20 +50,12 @@ function ValidateLoginPage({
5650
});
5751
}, [session?.autoAuthState]);
5852

59-
// No "Go Back" button: this is a deep-link entry point, so there is usually no history to pop back to.
60-
const loadingIndicator = <FullScreenLoadingIndicator shouldUseGoBackButton={false} />;
61-
62-
// Signed-in users are sent on by the effect above without waiting on a request, so only signed-out users need the offline view.
63-
if (!isOffline || isSignedIn) {
64-
return loadingIndicator;
65-
}
66-
6753
// Offline, the sign-in request waits in the queue until the network returns, so show why instead of a bare spinner.
68-
// The offline view has no background of its own, so paint one to cover whatever is underneath.
6954
return (
70-
<View style={[StyleSheet.absoluteFill, styles.appBG]}>
71-
<FullPageOfflineBlockingView>{loadingIndicator}</FullPageOfflineBlockingView>
72-
</View>
55+
<FullPageOfflineBlockingView>
56+
{/* No "Go Back" button: this is a deep-link entry point, so there is usually no history to pop back to. */}
57+
<FullScreenLoadingIndicator shouldUseGoBackButton={false} />
58+
</FullPageOfflineBlockingView>
7359
);
7460
}
7561

‎src/pages/ValidateLoginPage/index.web.tsx‎

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ import ExpiredValidateCodeModal from '@components/ValidateCode/ExpiredValidateCo
44
import JustSignedInModal from '@components/ValidateCode/JustSignedInModal';
55
import ValidateCodeModal from '@components/ValidateCode/ValidateCodeModal';
66

7-
import useNetwork from '@hooks/useNetwork';
87
import useOnyx from '@hooks/useOnyx';
9-
import useThemeStyles from '@hooks/useThemeStyles';
108

119
import Log from '@libs/Log';
1210
import Navigation from '@libs/Navigation/Navigation';
@@ -23,7 +21,6 @@ import type {OnyxEntry} from 'react-native-onyx';
2321

2422
import {useFocusEffect} from '@react-navigation/native';
2523
import React, {useCallback, useEffect, useState} from 'react';
26-
import {StyleSheet, View} from 'react-native';
2724

2825
import type ValidateLoginPageProps from './types';
2926

@@ -40,8 +37,6 @@ function ValidateLoginPage({
4037
const [account] = useOnyx(ONYXKEYS.ACCOUNT);
4138
const [credentials] = useOnyx(ONYXKEYS.CREDENTIALS);
4239
const [session] = useOnyx(ONYXKEYS.SESSION);
43-
const {isOffline} = useNetwork();
44-
const styles = useThemeStyles();
4540

4641
const login = credentials?.login;
4742
const isSignedIn = !!session?.authToken && session?.authTokenType !== CONST.AUTH_TOKEN_TYPES.ANONYMOUS;
@@ -168,17 +163,6 @@ function ValidateLoginPage({
168163
return () => clearTimeout(timeoutID);
169164
}, [isCompletingDirectSignIn, autoAuthStateWithDefault]);
170165

171-
const loadingIndicator = (
172-
<FullScreenLoadingIndicator
173-
// No "Go Back" button: this is a deep-link entry point, so there is usually no history to pop back to.
174-
shouldUseGoBackButton={false}
175-
testID="validate-login-loading"
176-
/>
177-
);
178-
// Offline, a signed-out user's sign-in request waits in the queue until the network returns, so show why instead of a bare spinner.
179-
// Signed-in users are sent on without waiting on a request, so they keep the loader.
180-
const shouldShowOfflineView = isOffline && !isSignedIn;
181-
182166
return (
183167
<>
184168
{autoAuthStateWithDefault === CONST.AUTO_AUTH_STATE.FAILED && !is2FARequired && <ExpiredValidateCodeModal />}
@@ -193,15 +177,16 @@ function ValidateLoginPage({
193177
code={validateCode}
194178
/>
195179
)}
196-
{((!effectiveAutoAuthState ? shouldStartSignInWithValidateCode : autoAuthStateWithDefault === CONST.AUTO_AUTH_STATE.SIGNING_IN) || isCompletingDirectSignIn) &&
197-
(shouldShowOfflineView ? (
198-
// The offline view has no background of its own, so paint one to cover whatever is underneath.
199-
<View style={[StyleSheet.absoluteFill, styles.appBG]}>
200-
<FullPageOfflineBlockingView>{loadingIndicator}</FullPageOfflineBlockingView>
201-
</View>
202-
) : (
203-
loadingIndicator
204-
))}
180+
{((!effectiveAutoAuthState ? shouldStartSignInWithValidateCode : autoAuthStateWithDefault === CONST.AUTO_AUTH_STATE.SIGNING_IN) || isCompletingDirectSignIn) && (
181+
// Offline, the sign-in request waits in the queue until the network returns, so show why instead of a bare spinner.
182+
<FullPageOfflineBlockingView>
183+
<FullScreenLoadingIndicator
184+
// No "Go Back" button: this is a deep-link entry point, so there is usually no history to pop back to.
185+
shouldUseGoBackButton={false}
186+
testID="validate-login-loading"
187+
/>
188+
</FullPageOfflineBlockingView>
189+
)}
205190
</>
206191
);
207192
}

‎tests/ui/LoadingIndicatorGoBackOptOutTest.tsx‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -181,11 +181,8 @@ describe('FullScreenLoadingIndicator "Go Back" opt-outs', () => {
181181
expect(screen.getByText('common.youAppearToBeOffline')).toBeOnTheScreen();
182182
expect(screen.UNSAFE_queryByType(ActivityIndicator)).toBeNull();
183183
} finally {
184-
// Network state is module-level, so restore it even if an assertion fails. The page is still
185-
// mounted and re-renders on the change, so do it inside act.
186-
act(() => {
187-
setHasRadio(true);
188-
});
184+
// Network state is module-level, so restore it even if an assertion fails
185+
setHasRadio(true);
189186
}
190187
});
191188

‎tests/ui/ValidateLoginPageTest.tsx‎

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -307,36 +307,9 @@ describe('ValidateLoginPage', () => {
307307
// Then the loader is back while the sign-in completes
308308
expect(screen.getByTestId('validate-login-loading')).toBeOnTheScreen();
309309
expect(screen.queryByText(translateLocal('common.youAppearToBeOffline'))).toBeNull();
310-
} finally {
311-
// Network state is module-level, so restore it even if an assertion fails. The page may still be
312-
// offline and mounted, so do it inside act.
313-
act(() => {
314-
setHasRadio(true);
315-
});
316-
}
317-
});
318-
319-
it('Should keep the loader, not the offline message, for a signed-in user who opens the link offline', async () => {
320-
// Given a signed-in user whose sign-in is still finishing, who is offline. They are sent on without
321-
// waiting on a request, so the offline message would only flash before the redirect.
322-
await act(async () => {
323-
await Onyx.set(ONYXKEYS.SESSION, {authToken: 'abcd', autoAuthState: CONST.AUTO_AUTH_STATE.SIGNING_IN});
324-
});
325-
setHasRadio(false);
326-
327-
try {
328-
// When they open the magic link
329-
renderPage({accountID: '1', validateCode: '123456'});
330-
await waitForBatchedUpdatesWithAct();
331-
332-
// Then they see the loader and no offline message
333-
expect(screen.getByTestId('validate-login-loading')).toBeOnTheScreen();
334-
expect(screen.queryByText(translateLocal('common.youAppearToBeOffline'))).toBeNull();
335310
} finally {
336311
// Network state is module-level, so restore it even if an assertion fails
337-
act(() => {
338-
setHasRadio(true);
339-
});
312+
setHasRadio(true);
340313
}
341314
});
342315

0 commit comments

Comments
 (0)