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

New skeleton loader for LHN #14456

Merged
merged 37 commits into from
Mar 23, 2023
Merged

New skeleton loader for LHN #14456

merged 37 commits into from
Mar 23, 2023

Conversation

bernhardoj
Copy link
Contributor

@bernhardoj bernhardoj commented Jan 21, 2023

Details

When we sign in to the app, a full screen loading indicator will be shown while loading the app data. Now, we want to show a skeleton instead while loading the required data.

Tagging @shawnborton for the design review.

Fixed Issues

$ #12698
PROPOSAL: #12698 (comment)

Tests

  1. Sign out if you are signed in
  2. Sign in back to the app
  3. Verify a skeleton is showing while loading the app data
  • Verify that no errors appear in the JS console

Offline tests

(I don't think we can test it when we are fully offline)

  1. Sign out if you are signed in
  2. Sign in back to the app
  3. Verify a skeleton is showing while loading the app data

QA Steps

  1. Sign out if you are signed in
  2. Sign in back to the app
  3. Verify a skeleton is showing while loading the app data
  • Verify that no errors appear in the JS console

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 the expected offline behavior in the Offline steps 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 tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android / native
    • Android / Chrome
    • iOS / native
    • iOS / Safari
    • MacOS / Chrome / Safari
    • 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 is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I verified the translation was requested/reviewed in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is correct English and approved by marketing by adding the Waiting for Copy label for a copy review 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
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • 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 */
    • 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 any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • 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.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • I have checked off every checkbox in the PR author checklist, including those that don't apply to this PR.

Screenshots/Videos

Web
Screen.Recording.2023-01-20.at.21.08.55.mov
Mobile Web - Chrome
329155.t.mp4
Mobile Web - Safari
Untitled.mov
Desktop
Screen.Recording.2023-01-20.at.21.46.22.mov
iOS
Screen.Recording.2023-01-20.at.21.20.17.mov
Android
329156.t.mp4

@bernhardoj bernhardoj requested a review from a team as a code owner January 21, 2023 05:53
@melvin-bot melvin-bot bot requested review from aimane-chnaif and roryabraham and removed request for a team January 21, 2023 05:53
@melvin-bot
Copy link

melvin-bot bot commented Jan 21, 2023

@roryabraham @aimane-chnaif One of you needs to copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@shawnborton
Copy link
Contributor

Almost! It looks like the fake sender/message preview is just slightly too far away from the avatars. Take a look here:
image

My guess is that those lines need to be 4px closer to the avatar.

@shawnborton shawnborton self-requested a review January 21, 2023 18:11
@shawnborton
Copy link
Contributor

Let me know if you need a new svg for that. We recently made it so that the space between all avatars and messages as 12px. So we might just need to update that svg everywhere, for both LHN and messages.

@bernhardoj
Copy link
Contributor Author

Yep, you are right, we need to adjust 4px closer to the avatar. Thanks for noticing that.

Updated the code.

@aimane-chnaif
Copy link
Contributor

aimane-chnaif commented Jan 22, 2023

bug.mov

@bernhardoj there are many weird issues in this video

  • reportID is added at the end of other page route
  • Report skeleton is showing forever
  • crash on LHN item click

Test step:

  • update Network to Slow 3G
  • Login
  • Open any other page before loading data (i.e. Click FAB + Split bill quickly or press Cmd+K shortcut to open Search page)

I think all of these are related to navigation code.

@bernhardoj
Copy link
Contributor Author

@aimane-chnaif Ah, I see. I think we should disable the FAB while loading, the same thing we do with search and setting button. But the search is still accessible from the keyboard shortcuts.

At first, I thought that we need to disable the shortcut too, but then I look at staging, we can open the search page while the full screen loading showing and I think the issue you see is the same which is the list is empty. So, I am not sure about this one. Should we also disable the shortcut?

@aimane-chnaif
Copy link
Contributor

@bernhardoj I think disabling other pages is a workaround. Can we fix this in navigation level?

@bernhardoj
Copy link
Contributor Author

I will try to find a safer way to update the params.

@bernhardoj
Copy link
Contributor Author

I have updated the setParams function to accept a route key parameter to update the params to the specified route key, not to the currently focused route. And to get the key of the report screen, we need to access it quite deep from the navigation state.

AuthScreen -> MainDrawerNavigator -> ReportScreen (key)
state         routes[0].state        routes[0].state.key

@aimane-chnaif
Copy link
Contributor

I'd like to get opinion from @shawnborton @roryabraham regarding user interaction on FAB menu before loading data

  1. hide FAB icon
  2. show FAB icon but disable user interaction on button click
  3. show popup menu on FAB click but disable user interaction on each item click
  4. don't prevent any user interactions and instead handle on each page
    Which is the best option?

@shawnborton
Copy link
Contributor

We've been having a similar conversation about how to handle the chat composer input when loading chats (cc @JmillsExpensify) and I think we landed with deciding that we shouldn't block the user interacting with the FAB or even navigating to the type of object they want to create from the FAB.

@bernhardoj
Copy link
Contributor Author

bernhardoj commented Jan 23, 2023

Maybe we can show a loading indicator while loading the data like the page here

Details Page

https://user-images.githubusercontent.com/50919443/214018965-a47b721b-82c5-449c-82b8-d32e7bc8d9e4.png

and update the list state when the data is ready.

@aimane-chnaif
Copy link
Contributor

@bernhardoj we opened discussion here so you can 👁️

@bernhardoj
Copy link
Contributor Author

I have removed the disable from the button. But I just tested that we can press New Workspace from the FAB menu while loading the initial data and it will lead to duplicate workspaces with the same name. Is this also out of scope and need to be handled on a seperate issue?

329278.t.mp4

@aimane-chnaif
Copy link
Contributor

I don't think we should allow those kinds of issues. Something like search list empty issues can be out of scope since they're already happening on production but those issues are critical and kind of regression.
@roryabraham what do you think?

@bernhardoj
Copy link
Contributor Author

So, I was trying to find a way for that FAB new workspace. I realize that when we open the app, App.openApp() will be called. It will load all the initial data and set IS_LOADING_REPORT_DATA while loading it. We can use this to hide the new workspace menu until the loading is finished.

diff --git a/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.js b/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.js
index 6fe0447ef..4520dda29 100644
--- a/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.js
+++ b/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.js
@@ -207,7 +207,7 @@ class FloatingActionButtonAndPopover extends React.Component {
                                 onSelected: () => Navigation.navigate(ROUTES.IOU_BILL),
                             },
                         ] : []),
-                        ...(!Policy.hasActiveFreePolicy(this.props.allPolicies) ? [
+                        ...(!this.props.isLoading && !Policy.hasActiveFreePolicy(this.props.allPolicies) ? [
                             {
                                 icon: Expensicons.NewWorkspace,
                                 iconWidth: 46,
@@ -247,5 +247,8 @@ export default compose(
         betas: {
             key: ONYXKEYS.BETAS,
         },
+        isLoading: {
+            key: ONYXKEYS.IS_LOADING_REPORT_DATA,
+        },
     }),
 )(FloatingActionButtonAndPopover);

With the IS_LOADING_REPORT_DATA key, this makes me think that maybe we can also use this to replace the emptiness condition of report and personal details. For example,

replace this
SidebarLink.js
const isLoading = _.isEmpty(this.props.personalDetails) || _.isEmpty(this.props.chatReports);

with the IS_LOADING_REPORT_DATA onyx key.

But the problem with this onyx key is that it will also be true when ReconnectApp is called. On Android (the device I tested), when we come from background, ReconnectApp will be called. This will make the skeleton will show again. So, maybe we can create a new key that is only set to true on OpenApp (like IS_LOADING_INITIAL_REPORT_DATA).

I am not sure whether this is the best approach or not because our current code uses the emptiness state of report/personal details and not using the IS_LOADING_REPORT_DATA.

Sorry if it's not clear.

What do you think? @aimane-chnaif @roryabraham

@aimane-chnaif
Copy link
Contributor

@roryabraham kindly bump for re-review

Copy link
Contributor

@roryabraham roryabraham left a comment

Choose a reason for hiding this comment

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

Only one very minor blocker in boolean variable name. Other than that I think this code looks good, but I'm a bit confused about why some of the changes were needed.

src/components/ReportHeaderSkeletonView.js Show resolved Hide resolved
src/pages/home/ReportScreen.js Outdated Show resolved Hide resolved
src/pages/home/ReportScreen.js Show resolved Hide resolved
src/pages/home/sidebar/SidebarLinks.js Outdated Show resolved Hide resolved
@aimane-chnaif
Copy link
Contributor

@roryabraham bump again for review!

@aimane-chnaif
Copy link
Contributor

aimane-chnaif commented Mar 13, 2023

@bernhardoj please fix pull from main. It seems conflict with #15897

@bernhardoj
Copy link
Contributor Author

Fixed. I also updated the freeze and animate variable to make it consistent with SidebarLinks.

@aimane-chnaif
Copy link
Contributor

@bernhardoj please fix conflict
@roryabraham bump again for review

@bernhardoj
Copy link
Contributor Author

bernhardoj commented Mar 21, 2023

Fixed. I also have retested the steps from this PR #15994 (which causes the conflict) and still works well.

@roryabraham roryabraham merged commit 359eb18 into Expensify:main Mar 23, 2023
@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.

@bernhardoj
Copy link
Contributor Author

bernhardoj commented Mar 23, 2023

Cool, finally 🥳. Thanks for the review @aimane-chnaif @roryabraham @shawnborton.

I guess the next step is to follow up on some issues here #14456 (comment). Here is the list of issues that I think we need to follow up:

  1. Empty search, new chat, new group, and probably iou participants
    We already have an issue for empty data here [HOLD for payment 2023-05-22] [$4000] Not showing any data on search page when press Cmd+K shortcut while loading after login #14490. I think we can use this issue specifically for these 4 pages because all of them use the same OptionsSelector, which means the same skeleton design (maybe we can even reuse the LHN skeleton).

  2. Empty profile page
    No issue created yet

  3. IOU participants error
    I already found out the root cause of the issue of this and we need a discussion what is the best way to handle it. The decision here may remove the need for iou participants skeleton from no. 1 (or maybe not because the user can still access it through the browser address bar directly).

  4. Empty IOU currency list
    No issue created yet

@aimane-chnaif
Copy link
Contributor

Minor console warning: (happens after login)
console warning

@bernhardoj can you investigate this?

@aimane-chnaif
Copy link
Contributor

Minor console warning: (happens after login)

Here's discussion: https://expensify.slack.com/archives/C01GTK53T8Q/p1679665614690159 (for reference)

@OSBotify
Copy link
Contributor

🚀 Deployed to staging by https://github.com/roryabraham in version: 1.2.89-0 🚀

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

@OSBotify
Copy link
Contributor

🚀 Deployed to production by https://github.com/luacmartins in version: 1.2.89-0 🚀

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

this.generateSkeletonViewItems(numItems);
}}
>
<View>{this.state.skeletonViewItems}</View>
Copy link
Contributor

Choose a reason for hiding this comment

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

Hi @bernhardoj, coming from #33163, Is there any specific reason that we didn't render SkeletonViewContentLoader directly via an array map function here, but pre-calculate and stored in this.state.skeletonViewItems in onLayout callback?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed it based on this suggestion. I think it's just for optimization.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks @bernhardoj

Copy link
Contributor

Choose a reason for hiding this comment

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

Hi @roryabraham, do you mind sharing the reason why you prefer to generate skeletonViewItems and store it in the component's state? In a first glance, I think it's because of optimization as @bernhardoj said above but I usually see the pattern where we generate a list/array of items (with a key) in component render function, leaving the rendering optimization part for React. Thanks

Copy link
Contributor

Choose a reason for hiding this comment

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

^ just in case you missed this message @roryabraham

Copy link
Contributor

Choose a reason for hiding this comment

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

Answered here

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.

6 participants