1
1
import { Str } from 'expensify-common' ;
2
2
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' ;
5
5
import type { OnyxEntry } from 'react-native-onyx' ;
6
6
import ColorSchemeWrapper from '@components/ColorSchemeWrapper' ;
7
7
import CustomStatusBarAndBackground from '@components/CustomStatusBarAndBackground' ;
@@ -24,7 +24,7 @@ import * as Session from '@userActions/Session';
24
24
import CONST from '@src/CONST' ;
25
25
import ONYXKEYS from '@src/ONYXKEYS' ;
26
26
import ROUTES from '@src/ROUTES' ;
27
- import type { Account , Credentials , Locale } from '@src/types/onyx' ;
27
+ import type { Account , Credentials } from '@src/types/onyx' ;
28
28
import { isEmptyObject } from '@src/types/utils/EmptyObject' ;
29
29
import ChooseSSOOrMagicCode from './ChooseSSOOrMagicCode' ;
30
30
import EmailDeliveryFailurePage from './EmailDeliveryFailurePage' ;
@@ -37,21 +37,7 @@ import UnlinkLoginForm from './UnlinkLoginForm';
37
37
import ValidateCodeForm from './ValidateCodeForm' ;
38
38
import type { BaseValidateCodeFormRef } from './ValidateCodeForm/BaseValidateCodeForm' ;
39
39
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 = {
55
41
shouldEnableMaxHeight ?: boolean ;
56
42
} ;
57
43
@@ -146,8 +132,18 @@ function getRenderOptions({
146
132
shouldShouldSignUpWelcomeForm,
147
133
} ;
148
134
}
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 ) ;
151
147
const styles = useThemeStyles ( ) ;
152
148
const StyleUtils = useStyleUtils ( ) ;
153
149
const { translate, formatPhoneNumber} = useLocalize ( ) ;
@@ -295,7 +291,6 @@ function SignInPage({credentials, account, activeClients = [], preferredLocale,
295
291
< ScreenWrapper
296
292
shouldShowOfflineIndicator = { false }
297
293
shouldEnableMaxHeight = { shouldEnableMaxHeight }
298
- shouldUseCachedViewportHeight
299
294
style = { [ styles . signInPage , StyleUtils . getSafeAreaPadding ( { ...safeAreaInsets , bottom : 0 , top : isInNarrowPaneModal ? 0 : safeAreaInsets . top } , 1 ) ] }
300
295
testID = { SignInPageThemeWrapper . displayName }
301
296
>
@@ -340,7 +335,6 @@ function SignInPage({credentials, account, activeClients = [], preferredLocale,
340
335
}
341
336
342
337
type SignInPageProps = SignInPageInnerProps ;
343
- type SignInPageOnyxProps = SignInPageInnerOnyxProps ;
344
338
const SignInPageWithRef = forwardRef ( SignInPage ) ;
345
339
346
340
function SignInPageThemeWrapper ( props : SignInPageProps , ref : ForwardedRef < SignInPageRef > ) {
@@ -362,20 +356,6 @@ function SignInPageThemeWrapper(props: SignInPageProps, ref: ForwardedRef<SignIn
362
356
363
357
SignInPageThemeWrapper . displayName = 'SignInPage' ;
364
358
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 ) ;
380
360
381
361
export type { SignInPageRef } ;
0 commit comments