From 3afa24a53b767220150bdeb706b6349fb8bb89b8 Mon Sep 17 00:00:00 2001 From: Brandon Stites Date: Tue, 3 May 2022 14:40:46 -0600 Subject: [PATCH 1/2] Refresh wait time if coming from offline to online --- src/pages/RequestCallPage.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/pages/RequestCallPage.js b/src/pages/RequestCallPage.js index 619b50f9b282..6ed36286ddd1 100644 --- a/src/pages/RequestCallPage.js +++ b/src/pages/RequestCallPage.js @@ -32,6 +32,8 @@ import * as ValidationUtils from '../libs/ValidationUtils'; import * as PersonalDetails from '../libs/actions/PersonalDetails'; import * as User from '../libs/actions/User'; import FormElement from '../components/FormElement'; +import {withNetwork} from '../components/OnyxProvider'; +import networkPropTypes from '../components/networkPropTypes'; const propTypes = { ...withLocalizePropTypes, @@ -79,6 +81,9 @@ const propTypes = { // The date that the user will be unblocked expiresAt: PropTypes.string, }), + + /** Information about the network from Onyx */ + network: networkPropTypes.isRequired, }; const defaultProps = { @@ -117,6 +122,18 @@ class RequestCallPage extends Component { } componentDidMount() { + this.fetchData(); + } + + componentDidUpdate(prevProps) { + if (!prevProps.network.isOffline || this.props.network.isOffline) { + return; + } + + this.fetchData(); + } + + fetchData() { // If it is the weekend don't check the wait time if (moment().day() === 0 || moment().day() === 6) { this.setState({ @@ -124,6 +141,7 @@ class RequestCallPage extends Component { }); return; } + Inbox.getInboxCallWaitTime(); } @@ -333,6 +351,7 @@ RequestCallPage.defaultProps = defaultProps; export default compose( withLocalize, + withNetwork(), withOnyx({ myPersonalDetails: { key: ONYXKEYS.MY_PERSONAL_DETAILS, From 09d24d758569460490c1fb8a14a5a3198f3d18ee Mon Sep 17 00:00:00 2001 From: Brandon Stites Date: Tue, 3 May 2022 14:42:47 -0600 Subject: [PATCH 2/2] Move fetchData for linter --- src/pages/RequestCallPage.js | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/pages/RequestCallPage.js b/src/pages/RequestCallPage.js index 6ed36286ddd1..04808471684b 100644 --- a/src/pages/RequestCallPage.js +++ b/src/pages/RequestCallPage.js @@ -133,18 +133,6 @@ class RequestCallPage extends Component { this.fetchData(); } - fetchData() { - // If it is the weekend don't check the wait time - if (moment().day() === 0 || moment().day() === 6) { - this.setState({ - onTheWeekend: true, - }); - return; - } - - Inbox.getInboxCallWaitTime(); - } - onSubmit() { if (!this.validateInputs()) { return; @@ -237,6 +225,18 @@ class RequestCallPage extends Component { return `${this.props.translate(waitTimeKey, {minutes: this.props.inboxCallUserWaitTime})} ${this.props.translate('requestCallPage.waitTime.guides')}`; } + fetchData() { + // If it is the weekend don't check the wait time + if (moment().day() === 0 || moment().day() === 6) { + this.setState({ + onTheWeekend: true, + }); + return; + } + + Inbox.getInboxCallWaitTime(); + } + validatePhoneInput() { this.setState({phoneNumberError: this.getPhoneNumberError()}); }