Skip to content
16 changes: 15 additions & 1 deletion src/components/OfflineIndicator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -31,7 +42,9 @@ const OfflineIndicator = (props) => {
<View style={[
props.isSmallScreenWidth ? styles.offlineIndicatorMobile : styles.offlineIndicator,
styles.flexRow,
styles.alignItemsCenter]}
styles.alignItemsCenter,
...StyleUtils.parseStyleAsArray(props.style),
]}
>
<Icon
src={Expensicons.Offline}
Expand All @@ -46,6 +59,7 @@ const OfflineIndicator = (props) => {
};

OfflineIndicator.propTypes = propTypes;
OfflineIndicator.defaultProps = defaultProps;
OfflineIndicator.displayName = 'OfflineIndicator';

export default compose(
Expand Down
1 change: 0 additions & 1 deletion src/libs/Network/enhanceParameters.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ function isAuthTokenRequired(command) {
'SetPassword',
'User_SignUp',
'ResendValidateCode',
'ResetPassword',
'User_ReopenAccount',
'ValidateEmail',
], command);
Expand Down
40 changes: 35 additions & 5 deletions src/libs/actions/Session/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
},
],
});
}

/**
Expand Down
12 changes: 0 additions & 12 deletions src/libs/deprecatedAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -756,7 +745,6 @@ export {
Report_GetHistory,
Report_EditComment,
ResendValidateCode,
ResetPassword,
SetNameValuePair,
SetPassword,
UpdatePolicy,
Expand Down
2 changes: 1 addition & 1 deletion src/pages/home/report/ReportActionCompose.js
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ class ReportActionCompose extends React.Component {
</View>
</View>
<View style={[styles.chatItemComposeSecondaryRow, styles.flexRow, styles.justifyContentBetween, styles.alignItemsCenter]}>
{!this.props.isSmallScreenWidth && <OfflineIndicator />}
{!this.props.isSmallScreenWidth && <OfflineIndicator style={[styles.chatItemComposeSecondaryRowOffset]} />}
<ReportTypingIndicator reportID={this.props.reportID} />
<ExceededCommentLength commentLength={this.comment.length} />
</View>
Expand Down
9 changes: 9 additions & 0 deletions src/pages/signin/ResendValidationForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -39,6 +42,9 @@ const propTypes = {
accountExists: PropTypes.bool,
}),

/** Information about the network */
network: networkPropTypes.isRequired,

...withLocalizePropTypes,
};

Expand Down Expand Up @@ -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}
/>
</View>
<OfflineIndicator />
</>
);
}
Expand All @@ -155,6 +163,7 @@ ResendValidationForm.defaultProps = defaultProps;

export default compose(
withLocalize,
withNetwork(),
withOnyx({
credentials: {key: ONYXKEYS.CREDENTIALS},
account: {key: ONYXKEYS.ACCOUNT},
Expand Down