Fix Firefox sorting room cards in the wrong direction #261
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 theObservableMap.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)[1, 2, 3, 4, 5].sort((a, b) => 1)
->[1, 2, 3, 4, 5]
✅[1, 2, 3, 4, 5].sort((a, b) => 1)
->[5, 4, 3, 2, 1]
❌