Skip to content

align gradient selection with cozy-ui frontend#4841

Merged
JF-Cozy merged 2 commits into
masterfrom
fix/avatar-colors-front-back-alignment
Jul 7, 2026
Merged

align gradient selection with cozy-ui frontend#4841
JF-Cozy merged 2 commits into
masterfrom
fix/avatar-colors-front-back-alignment

Conversation

@JF-Cozy

@JF-Cozy JF-Cozy commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Backend now matches cozy-ui's Avatar/helpers.js:

  • getInitialsColorHash uses rune iteration (like
    Array.from().charCodeAt()) instead of raw bytes
  • extractInfo now hashes the initials (getInitials) instead of
    the full publicName, matching cozy-ui which hashes whatever
    string is displayed as children
  • cozyUIAvatarColorSchemes is now an ordered slice in the same
    declaration order as cozy-ui's supportedColors, instead of
    an alphabetically-sorted map

This fixes two mismatches:

  1. Front-vs-back: both hash and palette selection are now
    identical, so the same input string produces the same
    gradient on both sides.

  2. Back-vs-back: /public/avatar?fallback=initials (public.go)
    passed the raw publicName to GenerateInitials, while
    /sharings/.../recipients/:idx/avatar (sharings.go:1080)
    pre-uppercased it with strings.ToUpper. The old case-
    sensitive byte hash produced different sums -> different
    gradients for the same person on two routes. Now extractInfo
    hashes the initials from the shared code path, so both routes
    hash the same string.

@JF-Cozy
JF-Cozy requested a review from a team as a code owner July 6, 2026 14:27
@JF-Cozy
JF-Cozy requested a review from shepilov July 6, 2026 14:28
JF-Cozy added 2 commits July 6, 2026 16:28
Backend now matches cozy-ui's Avatar/helpers.js:
- getInitialsColorHash uses rune iteration (like
  Array.from().charCodeAt()) instead of raw bytes
- extractInfo now hashes the initials (getInitials) instead of
  the full publicName, matching cozy-ui which hashes whatever
  string is displayed as children
- cozyUIAvatarColorSchemes is now an ordered slice in the same
  declaration order as cozy-ui's supportedColors, instead of
  an alphabetically-sorted map

This fixes two mismatches:

1. Front-vs-back: both hash and palette selection are now
   identical, so the same input string produces the same
   gradient on both sides.

2. Back-vs-back: /public/avatar?fallback=initials (public.go)
   passed the raw publicName to GenerateInitials, while
   /sharings/.../recipients/:idx/avatar (sharings.go:1080)
   pre-uppercased it with strings.ToUpper. The old case-
   sensitive byte hash produced different sums -> different
   gradients for the same person on two routes.  Now extractInfo
   hashes the initials from the shared code path, so both routes
   hash the same string.
@JF-Cozy
JF-Cozy force-pushed the fix/avatar-colors-front-back-alignment branch from 8330170 to 688954b Compare July 6, 2026 14:28
@JF-Cozy
JF-Cozy merged commit be6d914 into master Jul 7, 2026
4 checks passed
@JF-Cozy
JF-Cozy deleted the fix/avatar-colors-front-back-alignment branch July 7, 2026 08:07
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.

2 participants