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

Change balloon color selection to be stable per-balloon #325

Merged
merged 1 commit into from
Jun 26, 2024

Conversation

bismurphy
Copy link

When viewing SondeHub, a user will see some number of balloons in their view. Balloons are colored with a few different colors, to make it easy to tell them apart.

Currently, the color is selected by iterating through all the balloons, one by one, and each balloon gets a color from the list of colors, sequentially. Because balloons are iterated through in a non-deterministic manner (such that inserting or removing one balloon from the set will change the outcome of the others), viewing the set of balloons multiple times will result in the colors becoming re-shuffled. Therefore, refreshing the page, or viewing it on multiple devices (including viewing the site alongside a friend) will mean the same balloon will appear with different colors on different viewings.

This PR changes the logic such that the color is chosen by a hash of the callsign for the balloon, meaning that a given balloon will always show up with the same color for all viewers on all viewings. Because the balloon_index variable is no longer used, I have removed it.

@darksidelemm
Copy link
Member

Ooh, interesting idea. Can you point this to the testing branch please?
Then we can deploy it and it will show up at testing.v2.sondehub.org

@bismurphy bismurphy changed the base branch from master to testing June 26, 2024 22:25
@bismurphy
Copy link
Author

Thanks! Changed to testing, let me know if this introduces any issues!

@darksidelemm darksidelemm merged commit b1beb06 into projecthorus:testing Jun 26, 2024
@bismurphy bismurphy deleted the use_colorhash branch July 4, 2024 00:52
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.

None yet

2 participants