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 Fallback Avatar to Support Themes #38674

Merged
merged 20 commits into from
Apr 8, 2024
Merged

Conversation

grgia
Copy link
Contributor

@grgia grgia commented Mar 20, 2024

Details

This PR updates the fallback avatar to use the same coloring pattern we use for coloring the SVGs for the default workspace avatars

Example of the themes:

Screen.Recording.2024-03-20.at.2.55.46.PM.mov

Also changes the loading color from offline to borders. See #38674 (comment)

image ### NOTE

This PR only handles the SEARCH Bar, it does not fix this behavior all over the app (ie. chatting new users, manual request options, etc). That will be completed as part of this PR:
#38743

Outdated:

Example of users I know and don't know:

Screen.Recording.2024-03-20.at.1.22.31.PM.mov

If you don't know a user, don't have an account in ONYX, or in any cases where you'd only have an optimisticID, Then we will default to the fallback avatar.

Fixed Issues

$ #33161
#34000
#33470 (may impact testing steps for this one)

Tests

  • Verify that no errors appear in the JS console
  • Same as QA

Offline tests

QA Steps

  • Verify that no errors appear in the JS console
  • Trigger the fallback avatar to load by triggering an image error by going offline before loading the avatar of a user A with a cutom-uploaded avatar
  • ✅ Ensure that the fallback avatar is shown for that user
  • Toggle to the opposite theme
  • ✅ Ensure that the fallback avatar changes colors to match the theme (see description for video if you need a reference)

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: mWeb Chrome
    • iOS: Native
    • iOS: mWeb 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 the left part of a conditional rendering a React component is a boolean and NOT a string, e.g. myBool && <MyComponent />.
    • 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 grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
    • 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 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(theme.componentBG))
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • 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 the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • 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.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
MacOS: Desktop

@grgia grgia self-assigned this Mar 20, 2024
@grgia grgia changed the title Update Fallback Avatar Logic Update Fallback Avatar Logic for Search + Support Themes Mar 20, 2024
@grgia grgia marked this pull request as ready for review March 22, 2024 10:52
@grgia grgia requested a review from a team as a code owner March 22, 2024 10:52
@melvin-bot melvin-bot bot removed the request for review from a team March 22, 2024 10:52
Copy link

melvin-bot bot commented Mar 22, 2024

@dubielzyk-expensify @s77rt 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]

This comment has been minimized.

Copy link
Contributor

const isWorkspace = type === CONST.ICON_TYPE_WORKSPACE;
const iconSize = StyleUtils.getAvatarSize(size);

const imageStyle: StyleProp<ImageStyle> = [StyleUtils.getAvatarStyle(size), imageStyles, styles.noBorderRadius];
const iconStyle = imageStyles ? [StyleUtils.getAvatarStyle(size), styles.bgTransparent, imageStyles] : undefined;

const iconFillColor = isWorkspace ? StyleUtils.getDefaultWorkspaceAvatarColor(name).fill : fill;
// We pass the color styles down to the SVG for the workspace and fallback avatar.
const useFallBackAvatar = imageError || source === Expensicons.FallbackAvatar;
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
const useFallBackAvatar = imageError || source === Expensicons.FallbackAvatar;
const useFallBackAvatar = imageError || !source;
const avatarSource = useFallBackAvatar ? fallbackAvatar : source;

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 agree with this idea, but I'm worried there's a few places in app that are setting the fallback avatar as the avatar. For example here. Maybe we should just return nothing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seeing as this gets a little hazy, what if I remove this change from the PR (leaving only the theme support) and we handle all the fallback issues in #38743

Copy link
Contributor

Choose a reason for hiding this comment

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

Handling this separately sounds good to me 👍

userToInvite.icons = [
{
source: UserUtils.getAvatar('', optimisticAccountID),
source: FallbackAvatar,
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
source: FallbackAvatar,

Not specifying any source should by design fallback to the fallback avatart

Copy link
Contributor

Choose a reason for hiding this comment

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

I also found setting the source here causes imageError in Avatar in being true

src/components/Avatar.tsx Outdated Show resolved Hide resolved
@dubielzyk-expensify
Copy link
Contributor

Great stuff! There's this very brief flicker that happens between some of the searches. Could we eliminate this?

CleanShot.2024-03-25.at.09.28.30.mp4

Frozen down I see this:
CleanShot 2024-03-25 at 09 26 29@2x

Looks like it's the icon background color. If that's the default, then let's put it to button or borders so it matches the default avatar icon. I also see this icon color when I scroll my search very quickly before the avatars have loaded.

@Expensify Expensify deleted a comment from github-actions bot Mar 26, 2024
@grgia
Copy link
Contributor Author

grgia commented Mar 26, 2024

@s77rt okay, I removed the search changes from this PR and pushed suggestions. I've started a new test build :)

Copy link
Contributor

github-actions bot commented Apr 3, 2024

@grgia
Copy link
Contributor Author

grgia commented Apr 3, 2024

@dubielzyk-expensify just confirming- should the offline color for the icon look like this? (when a user has an avatar that's not able to load)

image

To do this,
I signed in on the adhoc build
I turned my wifi off
I searched for someone I know has a custom uploaded avatar

@dubielzyk-expensify
Copy link
Contributor

When offline we should use our fallback avatar:
CleanShot 2024-04-04 at 13 05 21@2x

@madmax330
Copy link
Contributor

@s77rt this is ready for final review

@s77rt
Copy link
Contributor

s77rt commented Apr 4, 2024

@madmax330 Still discussing unresolved comment #38674 (comment)

@grgia
Copy link
Contributor Author

grgia commented Apr 5, 2024

image @s77rt fixed

@grgia
Copy link
Contributor Author

grgia commented Apr 5, 2024

Rebuilding for easy testing

Copy link
Contributor

github-actions bot commented Apr 5, 2024

@melvin-bot melvin-bot bot requested a review from lakchote April 5, 2024 14:13
Copy link

melvin-bot bot commented Apr 5, 2024

@lakchote Please 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]

@madmax330 madmax330 merged commit 3525bf0 into main Apr 8, 2024
20 checks passed
@madmax330 madmax330 deleted the georgia-fallbackAvatars branch April 8, 2024 07:33
@OSBotify
Copy link
Contributor

OSBotify commented Apr 8, 2024

✋ 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 Apr 8, 2024

🚀 Deployed to staging by https://github.com/madmax330 in version: 1.4.61-0 🚀

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

@OSBotify
Copy link
Contributor

OSBotify commented Apr 8, 2024

🚀 Deployed to staging by https://github.com/madmax330 in version: 1.4.61-0 🚀

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

@OSBotify
Copy link
Contributor

🚀 Deployed to production by https://github.com/Julesssss in version: 1.4.61-8 🚀

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants