Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start using new new RequestCall Onyx-optimized API command instead of Inbox_CallUser #9573

Merged
merged 16 commits into from
Jul 7, 2022

Conversation

yuwenmemon
Copy link
Contributor

@yuwenmemon yuwenmemon commented Jun 27, 2022

@marcaaron, @neil-marcellini please review

HOLD ON https://github.com/Expensify/Web-Expensify/pull/34119

Details

Keeps the functionality pretty much the same, however, we now show a confirmation screen upon successfully requesting a call as opposed to a Growl.

Fixed Issues

$ https://github.com/Expensify/Expensify/issues/213428

Tests/QA

  1. Create a workspace if you do not already have one
  2. Click on your profile photo in the top left (Settings) -> Click on your workspace -> Click on the ❔ symbol in the top right -> "Request a setup call"
  3. Fill out the form but provide an invalid phone number, like 1243
  4. Make sure you see the following error show up on the form

Screen Shot 2022-06-27 at 1 22 45 PM

  1. Use a real phone number, make sure that you get a confirmation screen showing you have successfully request a call:

Screen Shot 2022-06-27 at 1 23 36 PM

  1. Confirm you get a text message confirming you have requested a call:
    IMG_8081
  • Verify that no errors appear in the JS console

PR Review Checklist

Contributor (PR Author) Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • iOS / native
    • Android / native
    • iOS / Safari
    • Android / Chrome
    • MacOS / Chrome
    • MacOS / Desktop
  • I verified there are no console errors (if there’s a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained “why” the code was doing something instead of only explaining “what” the code was doing.
    • I verified any copy / text shown in the product was added in all src/languages/* files
    • I verified any copy / text that was added to the app is correct English and approved by marketing by tagging the marketing team on the original GH to get the correct copy.
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named “index.js”. All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • Any functional components have the displayName property
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose and it is
  • If a new CSS style is added I verified that:
    • A similar style doesn’t already exist
    • The style can’t be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.

PR Reviewer Checklist

  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I checked that screenshots or videos are included for tests on all platforms
  • I verified tests pass on all platforms & I tested again on:
    • iOS / native
    • Android / native
    • iOS / Safari
    • Android / Chrome
    • MacOS / Chrome
    • MacOS / Desktop
  • I verified there are no console errors (if there’s a console error not related to the PR, report it or open an issue for it to be fixed)
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick).
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained “why” the code was doing something instead of only explaining “what” the code was doing.
    • I verified any copy / text shown in the product was added in all src/languages/* files
    • I verified any copy / text that was added to the app is correct English and approved by marketing by tagging the marketing team on the original GH to get the correct copy.
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named “index.js”. All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • Any functional components have the displayName property
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose and it is broken down into smaller components in order to separate concerns and functions
  • If a new CSS style is added I verified that:
    • A similar style doesn’t already exist
    • The style can’t be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.

Screenshots

Web

Kapture.2022-06-27.at.16.32.40.mp4

Mobile Web

Kapture.2022-06-27.at.16.49.03.mp4

Desktop

Kapture.2022-06-27.at.16.35.53.mp4

iOS

Kapture.2022-06-27.at.17.28.08.mp4

Android

@yuwenmemon yuwenmemon requested a review from a team as a code owner June 27, 2022 20:51
@yuwenmemon yuwenmemon self-assigned this Jun 27, 2022
@melvin-bot melvin-bot bot requested review from neil-marcellini and removed request for a team June 27, 2022 20:51
@yuwenmemon yuwenmemon force-pushed the yuwen-requestCall branch 2 times, most recently from 3bdfb77 to 1e08c0b Compare June 27, 2022 21:12
@yuwenmemon yuwenmemon requested a review from marcaaron June 27, 2022 21:19
@yuwenmemon yuwenmemon changed the title [HOLD Copy] Start using new new RequestCall Onyx-optimized API command instead of Inbox_CallUser [HOLD WEB#34119] Start using new new RequestCall Onyx-optimized API command instead of Inbox_CallUser Jun 27, 2022
Copy link
Contributor

@neil-marcellini neil-marcellini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks really good and it works well. I have a question about how we render the confirmation page, and we also need to have the blocking form implemented.

src/pages/RequestCallPage.js Show resolved Hide resolved
Comment on lines 362 to 370
<Button
success
pressOnEnter
onPress={this.onSubmit}
style={[styles.w100]}
text={this.props.translate('requestCallPage.callMe')}
isLoading={this.props.requestCallForm.loading}
isDisabled={isBlockedFromConcierge}
/>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To implement offline UX pattern C we need to disable this button, prevent the form from submitting, and show the user that they are offline.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes. Using FormAlertWithSubmitButton to fix this. Thanks!

neil-marcellini
neil-marcellini previously approved these changes Jul 1, 2022
Copy link
Contributor

@neil-marcellini neil-marcellini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, good to go from me. Let's see what @marcaaron has to say.

}
const data = [];

// Make sure we have a response (i.e. this isn't a promise being passed down to us by a failed retry request and responseData is undefined)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Make sure we have a response (i.e. this isn't a promise being passed down to us by a failed retry request and responseData is undefined)
// Make sure we have response data (i.e. response isn't a promise being passed down to us by a failed retry request and responseData is not undefined)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if I get this comment. response and not responseData is the part that would be a promise passed down to us by a failed retry request?

if (request.successData) {
data.push(...request.successData);
}
const data = [];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const onyxUpdates = [];

// Make sure we have a response (i.e. this isn't a promise being passed down to us by a failed retry request and responseData is undefined)
if (responseData) {
// Handle the request's success/failure data (client-side data)
if (responseData.jsonCode === 200 && request.successData) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like if we have request.failureData, but no request.successData and the responseData.jsonCode === 200 then the failureData will be pushed.

const data = [];

// Make sure we have a response (i.e. this isn't a promise being passed down to us by a failed retry request and responseData is undefined)
if (responseData) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NAB, I think this would be a little cleaner if we just returned early with the responseData if it's not defined.

src/libs/actions/Inbox.js Show resolved Hide resolved
Navigation.goBack();
return;
}
// Set loading spinner as we wait for the request to complete
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NAB, these details feel like something the UI should worry about. Not sure if the comments here help since the context is somewhere else.

src/libs/actions/Inbox.js Show resolved Hide resolved
onyxMethod: 'merge',
key: ONYXKEYS.ACCOUNT,
value: {
success: true,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is success: true for? Is this ACCOUNT data supposed to be here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah this will show the confirmation that the call was requested here:
https://github.com/Expensify/App/pull/9573/files#diff-2950751ea6e5a3b24fe47d391faa69d373aa4ee9d27dfdda253d7857beb1b9faR300-R303

This is similar to how the PasswordPage does it (and where I copied from):

/>
{!_.isEmpty(this.props.account.success)
? (
<PasswordConfirmationScreen />
) : (
<>

/** Holds information about the users account that is requesting the call */
account: PropTypes.shape({
/** Success state to show confirmation of requesting a call */
success: PropTypes.boolean,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be better to use requestCallForm to store this? account is pretty generic.

account.success doesn't really scream "Success state to show confirmation of requesting a call"

Maybe we can err on the side of being specific here and make it requestCallForm.didRequestCallSucceed or something?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah okay, sorry, this is carrying over from your comment above.

Yeah that works as an alternative for me 👍

@yuwenmemon
Copy link
Contributor Author

Updated!

Copy link
Contributor

@marcaaron marcaaron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM thanks for the changes!

Copy link
Contributor

@neil-marcellini neil-marcellini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to go.

@yuwenmemon yuwenmemon changed the title [HOLD WEB#34119] Start using new new RequestCall Onyx-optimized API command instead of Inbox_CallUser Start using new new RequestCall Onyx-optimized API command instead of Inbox_CallUser Jul 7, 2022
@yuwenmemon yuwenmemon merged commit 3c22789 into main Jul 7, 2022
@yuwenmemon yuwenmemon deleted the yuwen-requestCall branch July 7, 2022 16:33
@OSBotify
Copy link
Contributor

OSBotify commented Jul 7, 2022

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify
Copy link
Contributor

OSBotify commented Jul 8, 2022

🚀 Deployed to staging by @yuwenmemon in version: 1.1.81-0 🚀

platform result
🤖 android 🤖 failure ❌
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 failure ❌

@OSBotify
Copy link
Contributor

🚀 Deployed to production by @roryabraham in version: 1.1.82-5 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 failure ❌
🕸 web 🕸 success ✅

Comment on lines +15 to +24
if (!responseData) {
return;
}

// Handle the request's success/failure data (client-side data)
if (responseData.jsonCode === 200 && request.successData) {
onyxUpdates.push(...request.successData);
} else if (responseData.jsonCode !== 200 && request.failureData) {
onyxUpdates.push(...request.failureData);
}
Copy link
Contributor

@aldo-expensify aldo-expensify Aug 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @yuwenmemon

I'm not sure if this case matters, but if a requests hits the back end with a command that is not implemented, the backend returns a 404. I would have expected that the failureData to be pushed into Onyx, but it isn't because responseData is undefined so I ended up without feedback in the UI. Could this happen in a real case? like if we try to send a request about a workspace or a chat that doesn't exist anymore?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see what you mean because the response for that case does not come via jsonCode: https://github.com/Expensify/Web-Expensify/blob/30edfabd582f9ac70ec59cef3172a5bf25657efa/api.php#L2761-L2766

Maybe we can add a parameter that indicates if this call to the Middleware is coming from a failed retry request or not? Maybe checking the retryCount? Or check the HTTP response code somehow? The original issue was that if a request was a failed retry (i.e. could not connect to the Server), we'd have no responseData and thus get an undefined error.

However I don't really think this case matters too much right? Why would we want to support error messages for non-existent API commands? We shouldn't be calling non-existent API commands in the production App ever, right? Any "feedback in the UI" would solely be serving developers and that's it, no?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

However I don't really think this case matters too much right? Why would we want to support error messages for non-existent API commands? We shouldn't be calling non-existent API commands in the production App ever, right? Any "feedback in the UI" would solely be serving developers and that's it, no?

I completely agree that this doesn't matter if it only happens when a command doesn't exist, but I had my doubt if this could happen with other crashes like and exception being thrown. I'll test and let you know.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, retested throwing an exception in the web API, we get a jsonCode = 666, responseData is not undefined, and the failureData is applied correctly. I think this is the case that matters and works fine.. so lets do nothing :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants