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

Fix Firefox sorting room cards in the wrong direction #261

Merged

Conversation

MadLittleMods
Copy link
Contributor

@MadLittleMods MadLittleMods commented Jun 2, 2023

Fix Firefox sorting room cards in the wrong direction. They will now sort by room members descending (highest to lowest) as expected.

Fix #218

The /publicRooms (room directory) endpoint already returns rooms in the correct order which is why we didn't care about the order before but the different [].sort(...) implementations in browsers necessitates we be explicit about it. Ideally, we wouldn't have to use the ObservableMap.sortValues() method at all but it seems like one of the only ways to get the values out. In any case, maybe it's more clear what order things are in now.

Root cause

This bug stems from the fact that [1, 2, 3, 4, 5].sort((a, b) => 1) returns different results in Chrome vs Firefox (found from https://stackoverflow.com/questions/55039157/array-sort-behaves-differently-in-firefox-and-chrome-edge)

  • Chrome: [1, 2, 3, 4, 5].sort((a, b) => 1) -> [1, 2, 3, 4, 5]
  • Firefox: [1, 2, 3, 4, 5].sort((a, b) => 1) -> [5, 4, 3, 2, 1]
Before After

Fix #218

This stems from the fact that `[1, 2, 3, 4, 5].sort((a, b) => 1)` returns different results in Chrome vs Firefox (found from https://stackoverflow.com/questions/55039157/array-sort-behaves-differently-in-firefox-and-chrome-edge)

 - Chrome: `[1, 2, 3, 4, 5].sort((a, b) => 1)` -> `[1, 2, 3, 4, 5]`
 - Firefox: `[1, 2, 3, 4, 5].sort((a, b) => 1)` -> `[ 5, 4, 3, 2, 1 ]`
@MadLittleMods MadLittleMods added T-Defect Something isn't working. Bugs, crashes, or other reported issues. A-room-directory Room directory landing page where you can explore the list of rooms labels Jun 2, 2023
@MadLittleMods MadLittleMods marked this pull request as ready for review June 2, 2023 22:08
@MadLittleMods MadLittleMods merged commit c26bdc5 into main Jun 2, 2023
6 checks passed
MadLittleMods added a commit that referenced this pull request Jun 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-room-directory Room directory landing page where you can explore the list of rooms T-Defect Something isn't working. Bugs, crashes, or other reported issues.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sorting is different between browsers
1 participant