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

Username colors changed out of nowhere #26170

Closed
WolfspiritM opened this issue Sep 14, 2023 · 3 comments
Closed

Username colors changed out of nowhere #26170

WolfspiritM opened this issue Sep 14, 2023 · 3 comments
Labels

Comments

@WolfspiritM
Copy link

WolfspiritM commented Sep 14, 2023

Steps to reproduce

Compare old and new username colors for example for userid "@sometest:matrix.org".

image

Outcome

What did you expect?

Username colors staying the same

What happened instead?

Username colors changed drastically

As mention in another issue:
My color is completely different now and in conversations I always think I've a new message.
Especially confusing is that a friend has now a similar color I had before and I have now a color he had before.
Blue just became purple and purple became blue for example...

I always think I got a new message cause I got used to my color...

The reason is that the hashcode way that was implemented before worked differently.
(I still hope that there will be a way to set a custom color someday... (for everyone to see))

I think the old way was better cause it prevented someone with "misspelled" username to impersonate someone else. The new way produces the same color no matter in what order the letters are:

image
image

What makes me believe that this is a bug is that the name of the function doesn't do what it suggests:

https://github.com/vector-im/compound-web/blob/1b0bf41cf7782db098eb67b9e4de683a2fb32eac/src/components/Avatar/useIdColorHash.ts#L23C20-L23C20

It's not using a "hash" anymore. The function that got removed instead used a hash to do that:
matrix-org/matrix-react-sdk@e3df662#diff-1f693496f32ed3d0423cbc77412a1febdd04e3b0983a98ef06f8cd81262c8f9dL83

I think this is related to
#26042

Operating system

Windows

Application version

started with v1.11.41

How did you install the app?

No response

Homeserver

No response

Will you send logs?

No

@t3chguy
Copy link
Member

t3chguy commented Sep 14, 2023

It's not using a "hash" anymore.

Yes it is

A hash is:

assign a numeric or alphanumeric string to (a piece of data) by applying a function whose output values are all the same number of bits in length.

Given how Javascript represents numbers, this matches. It is a one-way function which maps a string to a number.

The new way produces the same color no matter in what order the letters are:

Fair, but this isn't a requirement for a hash function to be a valid function.

I suggest an issue on compound if you have an issue with its specific implementation.

element-hq/element-meta#2046 is the issue about the new colours

@t3chguy t3chguy closed this as completed Sep 14, 2023
@WolfspiritM
Copy link
Author

The new way produces the same color no matter in what order the letters are:

Fair, but this isn't a requirement for a hash function to be a valid function.

I didn't count that as a requirement for a hash function and I agree that summing up the char codes is some kind of "hash" aswell (even a very poor man one). It just felt like it was meant to be implemented the same way but somehow the part about the "ORing" which made the result less predictable (and yes, I know that is not a requirement for a hash aswell) got removed.

I added my comment to the other issue.

@MichaelSebero
Copy link

Every user in my group has a pink name now lol.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants