diff --git a/native/profile/delete-account.react.js b/native/profile/delete-account.react.js --- a/native/profile/delete-account.react.js +++ b/native/profile/delete-account.react.js @@ -17,9 +17,11 @@ } from 'lib/actions/user-actions'; import { preRequestUserStateSelector } from 'lib/selectors/account-selectors'; import { createLoadingStatusSelector } from 'lib/selectors/loading-selectors'; +import { accountHasPassword } from 'lib/shared/account-utils'; import type { LogOutResult } from 'lib/types/account-types'; import type { LoadingStatus } from 'lib/types/loading-types'; import type { PreRequestUserState } from 'lib/types/session-types'; +import type { CurrentUserInfo } from 'lib/types/user-types'; import type { DispatchActionPromise } from 'lib/utils/action-utils'; import { useServerCall, @@ -35,6 +37,7 @@ type Props = { // Redux state + +currentUserInfo: ?CurrentUserInfo, +loadingStatus: LoadingStatus, +preRequestUserState: PreRequestUserState, +activeTheme: ?GlobalTheme, @@ -44,16 +47,16 @@ +dispatchActionPromise: DispatchActionPromise, // async functions that hit server APIs +deleteAccount: ( - password: string, + password: ?string, preRequestUserState: PreRequestUserState, ) => Promise, }; type State = { - +password: string, + +password: ?string, }; class DeleteAccount extends React.PureComponent { state: State = { - password: '', + password: null, }; mounted = false; passwordInput: ?React.ElementRef; @@ -74,6 +77,30 @@ Delete account ); const { panelForegroundTertiaryLabel } = this.props.colors; + + let inputPasswordPrompt; + if (accountHasPassword(this.props.currentUserInfo)) { + inputPasswordPrompt = ( + <> + PASSWORD + + + + + ); + } return ( - PASSWORD - - - + {inputPasswordPrompt} @@ -239,6 +254,7 @@ const ConnectedDeleteAccount: React.ComponentType<{ ... }> = React.memo<{ ... }>(function ConnectedDeleteAccount() { + const currentUserInfo = useSelector(state => state.currentUserInfo); const loadingStatus = useSelector(loadingStatusSelector); const preRequestUserState = useSelector(preRequestUserStateSelector); const activeTheme = useSelector(state => state.globalThemeInfo.activeTheme); @@ -250,6 +266,7 @@ return (