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

Fall back to initials avatar when image avatar doesn't work #2667

Merged
merged 2 commits into from
Apr 8, 2024

Conversation

SpiritCroc
Copy link
Contributor

@SpiritCroc SpiritCroc commented Apr 7, 2024

Initially I had it implemented such that it would only fallback on error, but actually it's nice to have also while loading if it takes a while to load the avatar.

Type of change

  • Feature
  • Bugfix
  • Technical
  • Other :

Content

SubcomposeAsyncImage allows us to render the image or something else based on the render state, so we can render the initials avatar if the image doesn't load successfully

Motivation and context

I heard in the Element X chat that Element wants to have this (I had this in SchildiChat for a while already)

Screenshots / GIFs

Imagine some name-based fallback avatars in the roomlist like before, but also for contacts with broken mxc url

Tests

  • Tell somebody you're chatting with to run /myroomavatar mxc://broken on desktop
  • Observe their (lack of) avatar (before: would stay empty, now: falls back to initials avatar)

Tested devices

  • Physical
  • Emulator
  • OS version(s):

Checklist

Sign-off

Signed-off-by: Tobias Büttner dev@spiritcroc.de

@SpiritCroc SpiritCroc requested a review from a team as a code owner April 7, 2024 16:55
@SpiritCroc SpiritCroc requested review from bmarty and removed request for a team April 7, 2024 16:55
Copy link
Contributor

github-actions bot commented Apr 7, 2024

Thank you for your contribution! Here are a few things to check in the PR to ensure it's reviewed as quickly as possible:

  • Your branch should be based on origin/develop, at least when it was created.
  • There is a changelog entry in the changelog.d folder with the Towncrier format.
  • The test pass locally running ./gradlew test.
  • The code quality check suite pass locally running ./gradlew runQualityChecks.
  • If you modified anything related to the UI, including previews, you'll have to run the Record screenshots GH action in your forked repo: that will generate compatible new screenshots. However, given Github Actions limitations, it will prevent the CI from running temporarily, until you upload a new commit after that one. To do so, just pull the latest changes and push an empty commit.

Initially I had it implemented such that it would only fallback on
error, but actually it's nice to have also while loading if it takes
a while to load the avatar.
@SpiritCroc
Copy link
Contributor Author

SpiritCroc commented Apr 7, 2024

I guess the debugPlaceholderAvatar I removed was necessary for the paparazzi tests, maybe someone else can look into that, not sure what the preferred approach here would be (generate new reference screenshots? change behaviour for the test case with something like LocalInspectionMode.current?)

@bmarty bmarty added the Z-Community-PR Issue is solved by a community member's PR label Apr 8, 2024
Copy link
Member

@bmarty bmarty left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @SpiritCroc! Please see my answer about previews.

Copy link

codecov bot commented Apr 8, 2024

Codecov Report

Attention: Patch coverage is 80.00000% with 4 lines in your changes are missing coverage. Please review.

Project coverage is 73.48%. Comparing base (a46ff73) to head (e4b76e0).
Report is 6 commits behind head on develop.

Files Patch % Lines
...libraries/designsystem/components/avatar/Avatar.kt 80.00% 0 Missing and 4 partials ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #2667      +/-   ##
===========================================
- Coverage    73.48%   73.48%   -0.01%     
===========================================
  Files         1456     1456              
  Lines        35113    35126      +13     
  Branches      6733     6738       +5     
===========================================
+ Hits         25804    25813       +9     
  Misses        5793     5793              
- Partials      3516     3520       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@bmarty bmarty added the Run-Maestro Starts a Maestro Cloud session to run integration tests label Apr 8, 2024
Copy link
Member

@bmarty bmarty left a comment

Choose a reason for hiding this comment

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

Thanks for the update!

@bmarty bmarty enabled auto-merge April 8, 2024 09:50
@bmarty bmarty disabled auto-merge April 8, 2024 12:42
@bmarty bmarty merged commit 8128a59 into element-hq:develop Apr 8, 2024
15 of 16 checks passed
@SpiritCroc SpiritCroc deleted the avatar-fallback branch April 8, 2024 12:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Run-Maestro Starts a Maestro Cloud session to run integration tests Z-Community-PR Issue is solved by a community member's PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants