Skip to content

Commit 753de15

Browse files
authored
Merge pull request #52444 from bernhardoj/fix/51998-part-of-the-signin-magic-code-screen-is-blank
Fix blank space is shown on iOS safari when magic code screen show
2 parents 0a4bb9c + 2ad1111 commit 753de15

File tree

1 file changed

+17
-37
lines changed

1 file changed

+17
-37
lines changed

src/pages/signin/SignInPage.tsx

+17-37
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {Str} from 'expensify-common';
22
import React, {forwardRef, useEffect, useImperativeHandle, useRef, useState} from 'react';
3-
import type {ForwardedRef, RefAttributes} from 'react';
4-
import {withOnyx} from 'react-native-onyx';
3+
import type {ForwardedRef} from 'react';
4+
import {useOnyx} from 'react-native-onyx';
55
import type {OnyxEntry} from 'react-native-onyx';
66
import ColorSchemeWrapper from '@components/ColorSchemeWrapper';
77
import CustomStatusBarAndBackground from '@components/CustomStatusBarAndBackground';
@@ -24,7 +24,7 @@ import * as Session from '@userActions/Session';
2424
import CONST from '@src/CONST';
2525
import ONYXKEYS from '@src/ONYXKEYS';
2626
import ROUTES from '@src/ROUTES';
27-
import type {Account, Credentials, Locale} from '@src/types/onyx';
27+
import type {Account, Credentials} from '@src/types/onyx';
2828
import {isEmptyObject} from '@src/types/utils/EmptyObject';
2929
import ChooseSSOOrMagicCode from './ChooseSSOOrMagicCode';
3030
import EmailDeliveryFailurePage from './EmailDeliveryFailurePage';
@@ -37,21 +37,7 @@ import UnlinkLoginForm from './UnlinkLoginForm';
3737
import ValidateCodeForm from './ValidateCodeForm';
3838
import type {BaseValidateCodeFormRef} from './ValidateCodeForm/BaseValidateCodeForm';
3939

40-
type SignInPageInnerOnyxProps = {
41-
/** The details about the account that the user is signing in with */
42-
account: OnyxEntry<Account>;
43-
44-
/** The credentials of the person signing in */
45-
credentials: OnyxEntry<Credentials>;
46-
47-
/** Active Clients connected to ONYX Database */
48-
activeClients: OnyxEntry<string[]>;
49-
50-
/** The user's preferred locale */
51-
preferredLocale: OnyxEntry<Locale>;
52-
};
53-
54-
type SignInPageInnerProps = SignInPageInnerOnyxProps & {
40+
type SignInPageInnerProps = {
5541
shouldEnableMaxHeight?: boolean;
5642
};
5743

@@ -146,8 +132,18 @@ function getRenderOptions({
146132
shouldShouldSignUpWelcomeForm,
147133
};
148134
}
149-
150-
function SignInPage({credentials, account, activeClients = [], preferredLocale, shouldEnableMaxHeight = true}: SignInPageInnerProps, ref: ForwardedRef<SignInPageRef>) {
135+
function SignInPage({shouldEnableMaxHeight = true}: SignInPageInnerProps, ref: ForwardedRef<SignInPageRef>) {
136+
const [credentials] = useOnyx(ONYXKEYS.CREDENTIALS);
137+
const [account] = useOnyx(ONYXKEYS.ACCOUNT);
138+
/**
139+
This variable is only added to make sure the component is re-rendered
140+
whenever the activeClients change, so that we call the
141+
ActiveClientManager.isClientTheLeader function
142+
everytime the leader client changes.
143+
We use that function to prevent repeating code that checks which client is the leader.
144+
*/
145+
const [activeClients] = useOnyx(ONYXKEYS.ACTIVE_CLIENTS);
146+
const [preferredLocale] = useOnyx(ONYXKEYS.NVP_PREFERRED_LOCALE);
151147
const styles = useThemeStyles();
152148
const StyleUtils = useStyleUtils();
153149
const {translate, formatPhoneNumber} = useLocalize();
@@ -295,7 +291,6 @@ function SignInPage({credentials, account, activeClients = [], preferredLocale,
295291
<ScreenWrapper
296292
shouldShowOfflineIndicator={false}
297293
shouldEnableMaxHeight={shouldEnableMaxHeight}
298-
shouldUseCachedViewportHeight
299294
style={[styles.signInPage, StyleUtils.getSafeAreaPadding({...safeAreaInsets, bottom: 0, top: isInNarrowPaneModal ? 0 : safeAreaInsets.top}, 1)]}
300295
testID={SignInPageThemeWrapper.displayName}
301296
>
@@ -340,7 +335,6 @@ function SignInPage({credentials, account, activeClients = [], preferredLocale,
340335
}
341336

342337
type SignInPageProps = SignInPageInnerProps;
343-
type SignInPageOnyxProps = SignInPageInnerOnyxProps;
344338
const SignInPageWithRef = forwardRef(SignInPage);
345339

346340
function SignInPageThemeWrapper(props: SignInPageProps, ref: ForwardedRef<SignInPageRef>) {
@@ -362,20 +356,6 @@ function SignInPageThemeWrapper(props: SignInPageProps, ref: ForwardedRef<SignIn
362356

363357
SignInPageThemeWrapper.displayName = 'SignInPage';
364358

365-
export default withOnyx<SignInPageProps & RefAttributes<SignInPageRef>, SignInPageOnyxProps>({
366-
account: {key: ONYXKEYS.ACCOUNT},
367-
credentials: {key: ONYXKEYS.CREDENTIALS},
368-
/**
369-
This variable is only added to make sure the component is re-rendered
370-
whenever the activeClients change, so that we call the
371-
ActiveClientManager.isClientTheLeader function
372-
everytime the leader client changes.
373-
We use that function to prevent repeating code that checks which client is the leader.
374-
*/
375-
activeClients: {key: ONYXKEYS.ACTIVE_CLIENTS},
376-
preferredLocale: {
377-
key: ONYXKEYS.NVP_PREFERRED_LOCALE,
378-
},
379-
})(forwardRef(SignInPageThemeWrapper));
359+
export default forwardRef(SignInPageThemeWrapper);
380360

381361
export type {SignInPageRef};

0 commit comments

Comments
 (0)