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

Update Global Offline Indicator #9895

Merged
merged 18 commits into from
Jul 20, 2022
Merged

Conversation

jasperhuangg
Copy link
Contributor

@jasperhuangg jasperhuangg commented Jul 13, 2022

See issue for more context.

Fixed Issues

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

Tests

  1. Sign into an account on NewDot.
  2. Turn off your wifi.
  3. Verify that the OfflineIndicator appears (see screen captures).
  4. Turn on your wifi.
  5. Verify that the OfflineIndicator goes away.
  6. Repeat on all platforms.

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 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.
  • I have checked off every checkbox in the PR author checklist, including those that don't apply to this PR.

PR Reviewer Checklist

The Contributor+ will copy/paste it into a new comment and complete it after the author checklist is completed

  • I have verified the author checklist is complete (all boxes are checked off).
  • 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 other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • 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.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

QA Steps

  1. Sign into an account on NewDot.
  2. Turn off your wifi.
  3. Verify that the OfflineIndicator appears (see screen captures).
  4. Turn on your wifi.
  5. Verify that the OfflineIndicator goes away.
  6. Repeat on all platforms.

Screenshots

Web

Screen Shot 2022-07-13 at 4 07 14 PM

Mobile Web

Screen Shot 2022-07-18 at 6 19 49 PM

Desktop

Screen Shot 2022-07-13 at 4 06 57 PM

iOS

Screen Shot 2022-07-18 at 6 42 06 PM

Android

Screen Shot 2022-07-13 at 4 28 02 PM

@jasperhuangg jasperhuangg self-assigned this Jul 13, 2022
@jasperhuangg jasperhuangg marked this pull request as ready for review July 13, 2022 23:31
@jasperhuangg jasperhuangg requested a review from a team as a code owner July 13, 2022 23:31
@melvin-bot melvin-bot bot requested review from arosiclair and removed request for a team July 13, 2022 23:31
Copy link
Contributor

@iwiznia iwiznia left a comment

Choose a reason for hiding this comment

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

Looks great, but seems on mobile the indicator has too much space on top of it, is there something we can do to reduce that?

src/components/ScreenWrapper.js Outdated Show resolved Hide resolved
@jasperhuangg
Copy link
Contributor Author

jasperhuangg commented Jul 14, 2022

@iwiznia @arosiclair Ah, it's because of this view at the bottom of ReportActionCompose (which houses the ReportTypingIndicator and ExceededCommentLength components).

If we want to display the OfflineIndicator in the ScreenWrapper component on mobile (which is the parent component of ReportActionCompose), it'll always be underneath that view, and the view will look like extra padding.

The space does look kinda weird, but the offline indicator isn't actually cut-off on mobile (it just looked that way because of my bad screenshot skillz). That red space underneath the text input is the aforementioned view.

Screen Shot 2022-07-14 at 3 54 56 PM

You can see that on bigger screens we render the OfflineIndicator inside of that view, so it looks fine:

Screen Shot 2022-07-14 at 4 02 00 PM

One solution I'm thinking of is to just not render that view in ReportActionCompose if we're on a small screen and we're offline. If we're offline the ReportTypingIndicator is useless, and we could re-render the ExceededCommentLength component somewhere else. Although this would also require conditionally altering the minHeight style applied to ReportActionCompose here. This all seems like too much for such a small issue.

Any other ideas?

@iwiznia
Copy link
Contributor

iwiznia commented Jul 14, 2022

One solution I'm thinking of is to just not render that view in ReportActionCompose

The ReportTypingIndicator right?

and we could re-render the ExceededCommentLength component somewhere else

hmmm like where?

This all seems like too much for such a small issue.

I don't know, it does not look great... can we see how it looks in other pages? Like the LHN or settings page?

@jasperhuangg
Copy link
Contributor Author

jasperhuangg commented Jul 15, 2022

@iwiznia

The ReportTypingIndicator right?

I meant this entire view that's highlighted here. This view is the thing that's pushing the offline indicator down and creating that artificial padding on smaller screens.

@jasperhuangg
Copy link
Contributor Author

@iwiznia @arosiclair I honestly think that extra vertical padding makes sense, because it leaves us space to show the ExceededCommentLength component like so:
Screen Shot 2022-07-15 at 12 30 00 PM

@iwiznia
Copy link
Contributor

iwiznia commented Jul 15, 2022

Maybe...

can we see how it looks in other pages? Like the LHN or settings page?

@arosiclair
Copy link
Contributor

I would try adding some padding around the indicator in the ScreenWrapper so it doesn't look so squished at the bottom. Aside from that, I do think there is an issue with the safe area since the indicator appears below the iOS home bar and the safe area should account for that. Or did you already fix that?

@jasperhuangg
Copy link
Contributor Author

@arosiclair

Aside from that, I do think there is an issue with the safe area since the indicator appears below the iOS home bar and the safe area should account for that.

Ah I see what you mean! I do think this should be fixed, let me take a look.

@jasperhuangg
Copy link
Contributor Author

jasperhuangg commented Jul 18, 2022

can we see how it looks in other pages? Like the LHN or settings page?

Yup, the safe area insets are definitely messed up.. the offline indicator looks different on almost every page. I figured it would have been handled by this, but it appears that that doesn't actually work:
Screen Shot 2022-07-18 at 9 26 51 AM
Screen Shot 2022-07-18 at 9 26 55 AM
Screen Shot 2022-07-18 at 9 26 58 AM

Changing this View to a SafeAreaView fixes all the problems, which is making me wonder why we're even setting the SafeAreaInsets manually via a the SafeAreaInsetConsumer. Asked about it in #expensify-open-source here.

@iwiznia @arosiclair

@jasperhuangg
Copy link
Contributor Author

Ah, after some investigation it appears that we're using the consumer to set the insets manually because we don't want the safe area padding on mobile for the reports list. This allows the report list to extend past the notch

Screen Shot 2022-07-18 at 10 20 49 AM

Therefore, I've added a line here to ensure that the padding bottom is always there if we're offline. This fixes the issue
Screen Shot 2022-07-18 at 10 37 52 AM
Screen Shot 2022-07-18 at 10 37 55 AM

@jasperhuangg
Copy link
Contributor Author

jasperhuangg commented Jul 18, 2022

@arosiclair @iwiznia

It appears the safe area insets don't get applied whenever we have a KeyboardAvoidingView nested inside of the ScreenWrapper. This means the offline indicator will get cut off by the notch. This is the ProfilePage with the KeyboardAvoidingView:

Screen Shot 2022-07-18 at 10 53 08 AM

With the KeyboardAvoidingView commented out:

Screen Shot 2022-07-18 at 10 53 19 AM

I figured out that you can actually avoid this if you reverse the nesting of the ScreenWrapper and KeyboardAvoidingView. The only thing is, there are already sooo many components (20+) that already have the KeyboardAvoidingView nested inside of the ScreenWrapper. If we want the offline indicator to appear correctly on these pages, we'll need to reverse the nesting for all of them.

@jasperhuangg
Copy link
Contributor Author

@iwiznia Something else just came to my attention, we actually have another component called the FormAlertWrapper that also handles showing an offline indicator. That means on pages like the Payments Page which include both a ScreenWrapper and FormAlertWrapper, 2 offline indicators appear:

Screen Shot 2022-07-18 at 11 17 39 AM

If we're globalizing the offline indicator to the screen wrapper, we should get rid of the offline indicator in the FormAlertWrapper, right?

@iwiznia
Copy link
Contributor

iwiznia commented Jul 18, 2022

If we're globalizing the offline indicator to the screen wrapper, we should get rid of the offline indicator in the FormAlertWrapper, right?

Yes, either I missed that usage or it was added after I looked.

As for the other issue, seems like you got the solution figured out, right?

Copy link
Contributor

@arosiclair arosiclair left a comment

Choose a reason for hiding this comment

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

We need some spacing around the offline indicator. It looks good in the report action compose section, but the global indicator elsewhere doesn't have any spacing and looks squished. See the below screenshots

Screen Shot 2022-07-20 at 12 25 30 PM

Screen Shot 2022-07-20 at 12 26 22 PM

We should match the spacing on the ReportActionCompose indicator for consistency and to give it some breathing room that'll make it easier to read.

@jasperhuangg jasperhuangg dismissed stale reviews from marcaaron and iwiznia via 62c192d July 20, 2022 17:58
@jasperhuangg
Copy link
Contributor Author

@arosiclair I've added the same amount of padding that's being used on the ReportActionCompose component to the OfflineIndicator in the ScreenWrapper:
Screen Shot 2022-07-20 at 11 00 30 AM

Copy link
Contributor

@arosiclair arosiclair left a comment

Choose a reason for hiding this comment

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

Looks good and tests well. Thanks for the changes!

@arosiclair arosiclair merged commit 025dcf7 into main Jul 20, 2022
@arosiclair arosiclair deleted the jasper-updateGlobalOfflineIndicator branch July 20, 2022 19:24
@melvin-bot
Copy link

melvin-bot bot commented Jul 20, 2022

@arosiclair looks like this was merged without passing tests. Please add a note explaining why this was done and remove the Emergency label if this is not an emergency.

@melvin-bot melvin-bot bot added the Emergency label Jul 20, 2022
@OSBotify
Copy link
Contributor

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

@arosiclair
Copy link
Contributor

Tests passed I dunno what the deal is with this Emergency label behavior

@OSBotify
Copy link
Contributor

🚀 Deployed to staging by @arosiclair in version: 1.1.86-0 🚀

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

@OSBotify
Copy link
Contributor

OSBotify commented Aug 1, 2022

🚀 Deployed to production by @yuwenmemon in version: 1.1.86-5 🚀

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

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