diff --git a/src/components/OfflineIndicator.js b/src/components/OfflineIndicator.js index b3e2fd830354..0a450e649db6 100644 --- a/src/components/OfflineIndicator.js +++ b/src/components/OfflineIndicator.js @@ -10,18 +10,29 @@ import Text from './Text'; import styles from '../styles/styles'; import compose from '../libs/compose'; import withLocalize, {withLocalizePropTypes} from './withLocalize'; +import * as StyleUtils from '../styles/StyleUtils'; import withWindowDimensions from './withWindowDimensions'; const propTypes = { /** Information about the network */ network: networkPropTypes.isRequired, + /** Additional styles to add after local styles. */ + style: PropTypes.oneOfType([ + PropTypes.arrayOf(PropTypes.object), + PropTypes.object, + ]), + /** Is the window width narrow, like on a mobile device */ isSmallScreenWidth: PropTypes.bool.isRequired, ...withLocalizePropTypes, }; +const defaultProps = { + style: [], +}; + const OfflineIndicator = (props) => { if (!props.network.isOffline) { return null; @@ -31,7 +42,9 @@ const OfflineIndicator = (props) => { { }; OfflineIndicator.propTypes = propTypes; +OfflineIndicator.defaultProps = defaultProps; OfflineIndicator.displayName = 'OfflineIndicator'; export default compose( diff --git a/src/libs/Network/enhanceParameters.js b/src/libs/Network/enhanceParameters.js index 9c7356685ce1..093c0d96c087 100644 --- a/src/libs/Network/enhanceParameters.js +++ b/src/libs/Network/enhanceParameters.js @@ -19,7 +19,6 @@ function isAuthTokenRequired(command) { 'SetPassword', 'User_SignUp', 'ResendValidateCode', - 'ResetPassword', 'User_ReopenAccount', 'ValidateEmail', ], command); diff --git a/src/libs/actions/Session/index.js b/src/libs/actions/Session/index.js index 95673cc696af..feddc53e755a 100644 --- a/src/libs/actions/Session/index.js +++ b/src/libs/actions/Session/index.js @@ -302,11 +302,41 @@ function signInWithShortLivedToken(email, shortLivedToken) { * User forgot the password so let's send them the link to reset their password */ function resetPassword() { - Onyx.merge(ONYXKEYS.ACCOUNT, {loading: true, forgotPassword: true}); - DeprecatedAPI.ResetPassword({email: credentials.login}) - .finally(() => { - Onyx.merge(ONYXKEYS.ACCOUNT, {loading: false, validateCodeExpired: false}); - }); + API.write('RequestPasswordReset', { + email: credentials.login, + }, + { + optimisticData: [ + { + onyxMethod: 'merge', + key: ONYXKEYS.ACCOUNT, + value: { + isLoading: true, + forgotPassword: true, + }, + }, + ], + successData: [ + { + onyxMethod: 'merge', + key: ONYXKEYS.ACCOUNT, + value: { + isLoading: false, + validateCodeExpired: false, + }, + }, + ], + failureData: [ + { + onyxMethod: 'merge', + key: ONYXKEYS.ACCOUNT, + value: { + isLoading: false, + validateCodeExpired: false, + }, + }, + ], + }); } /** diff --git a/src/libs/deprecatedAPI.js b/src/libs/deprecatedAPI.js index 77c76ee48861..5042475d22b9 100644 --- a/src/libs/deprecatedAPI.js +++ b/src/libs/deprecatedAPI.js @@ -328,17 +328,6 @@ function SetNameValuePair(parameters) { return Network.post(commandName, parameters); } -/** - * @param {Object} parameters - * @param {string} parameters.email - * @returns {Promise} - */ -function ResetPassword(parameters) { - const commandName = 'ResetPassword'; - requireParameters(['email'], parameters, commandName); - return Network.post(commandName, parameters); -} - /** * @param {Object} parameters * @param {String} parameters.password @@ -756,7 +745,6 @@ export { Report_GetHistory, Report_EditComment, ResendValidateCode, - ResetPassword, SetNameValuePair, SetPassword, UpdatePolicy, diff --git a/src/pages/home/report/ReportActionCompose.js b/src/pages/home/report/ReportActionCompose.js index 9b441aa4dbc3..12fb896ea1e3 100755 --- a/src/pages/home/report/ReportActionCompose.js +++ b/src/pages/home/report/ReportActionCompose.js @@ -669,7 +669,7 @@ class ReportActionCompose extends React.Component { - {!this.props.isSmallScreenWidth && } + {!this.props.isSmallScreenWidth && } diff --git a/src/pages/signin/ResendValidationForm.js b/src/pages/signin/ResendValidationForm.js index 701cc41d8561..6d55b4683898 100755 --- a/src/pages/signin/ResendValidationForm.js +++ b/src/pages/signin/ResendValidationForm.js @@ -14,6 +14,9 @@ import compose from '../../libs/compose'; import redirectToSignIn from '../../libs/actions/SignInRedirect'; import Avatar from '../../components/Avatar'; import * as ReportUtils from '../../libs/ReportUtils'; +import OfflineIndicator from '../../components/OfflineIndicator'; +import networkPropTypes from '../../components/networkPropTypes'; +import {withNetwork} from '../../components/OnyxProvider'; const propTypes = { /* Onyx Props */ @@ -39,6 +42,9 @@ const propTypes = { accountExists: PropTypes.bool, }), + /** Information about the network */ + network: networkPropTypes.isRequired, + ...withLocalizePropTypes, }; @@ -143,8 +149,10 @@ class ResendValidationForm extends React.Component { text={this.props.translate('resendValidationForm.resendLink')} isLoading={this.props.account.loading} onPress={this.validateAndSubmitForm} + isDisabled={this.props.network.isOffline} /> + ); } @@ -155,6 +163,7 @@ ResendValidationForm.defaultProps = defaultProps; export default compose( withLocalize, + withNetwork(), withOnyx({ credentials: {key: ONYXKEYS.CREDENTIALS}, account: {key: ONYXKEYS.ACCOUNT},