Skip to content
This repository was archived by the owner on Aug 21, 2025. It is now read-only.

Fix avatar scaling issue when expanding the header in the Avatar tab#108

Merged
AdamGrzybkowski merged 3 commits intotrunkfrom
adam/GRA-657
Aug 13, 2025
Merged

Fix avatar scaling issue when expanding the header in the Avatar tab#108
AdamGrzybkowski merged 3 commits intotrunkfrom
adam/GRA-657

Conversation

@AdamGrzybkowski
Copy link
Contributor

Description

There's a problem with the avatar scaling animation when expanding the header after the image is selected. The avatar isn't scaling properly (only the outer component).

I noticed the issue would only happen when the image was not in the cache. Selecting an image that was already selected before would work just fine. The callback that sets the oldImageKey is invoked multiple times, so my guess is that it's related to extra recompositions... but not 100% sure.

Adding a check and only setting the oldImageKey to a new value seems to solve the issue.

Additionally, I've simplified the GravatarAvatarWithShadow code. The behavior should still be the same: a placeholder visible at all times, when loading a new avatar, the old one should stay visible until the new one is loaded.

Before After
avatar_scale_before avatar_scale_after

Testing Steps

  1. Perform a fresh installation of the app (or delete the app cache)
  2. Log in
  3. Collapse the header
  4. Select a new avatar
  5. Expand the header
  6. Confirm the avatar looks good
  7. Collapse the header
  8. Select the previous avatar (to load from cache)
  9. Expand the header
  10. Confirm the avatar looks good
  11. Confirm that the old avatar is always visible untill the new one is loaded

@AdamGrzybkowski AdamGrzybkowski added the bug Something isn't working label Aug 12, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes an avatar scaling animation issue that occurs when expanding the header in the Avatar tab after selecting a new image. The problem was caused by multiple recompositions triggering the oldImageKey callback repeatedly, which interfered with the scaling animation for non-cached images.

  • Fixed callback handling to only update oldImageKey when the value actually changes
  • Simplified GravatarAvatarWithShadow component by removing unnecessary state management
  • Maintained the core functionality of showing placeholder until new avatar loads

Reviewed Changes

Copilot reviewed 2 out of 4 changed files in this pull request and generated 2 comments.

File Description
GravatarAvatarWithShadow.kt Simplified component by removing loading state tracking and Box wrapper
AsyncImageWithCachePlaceholder.kt Fixed callback logic to prevent unnecessary oldImageKey updates

Copy link
Contributor

@etoledom etoledom left a comment

Choose a reason for hiding this comment

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

Nice! The issue is not reproducible any longer 🎉

@AdamGrzybkowski AdamGrzybkowski merged commit 1c4f83f into trunk Aug 13, 2025
10 checks passed
@AdamGrzybkowski AdamGrzybkowski deleted the adam/GRA-657 branch August 13, 2025 11:25
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants