-
-
Notifications
You must be signed in to change notification settings - Fork 827
Flatten and simplify the memberlist sorting algorithm #2381
Conversation
Would it make sense to file a separate issue to track this? It seems like something where we'd want to write a test for the correct behavior (and hopefully also fix whatever prevents it currently). |
I think the emit problem may be matrix-org/matrix-js-sdk#404 or a very similar issue. |
Would be possible to add test coverage for this change? It seems complex enough that test coverage would help me understand what's supposed to happen as a reviewer (who isn't familiar with this area) and also help verify it continues to work that way in the future. |
In theory the comments in the diff and the PR description highlight the intended behaviour (and the complexity of the problem). I'll look into some sort of testing though - not sure how we actually do testing for this kind of thing. |
The previous algorithm had a bug where it was getting stuck on the power level comparison, leaving the memberlist incorrectly ordered. The new algorithm uses less branching to try and walk through the different cases instead. Additionally, the steps used to determine the order have changed slightly to better represent an active member list. This commit also includes changes to try and re-sort the member list more often during presence changes. Events are not always emitted, however. This may be a js-sdk bug but appears to happen prior to these changes as well. Fixes element-hq/element-web#6953
They are useful to have around, but not to have enabled all the time.
32f727b
to
95844eb
Compare
Particularly the ordering of the tiles.
Time is backwards from all the other tests: larger is older, so we want LessThanOrEqual. Also ensure all the power levels are the same to prevent the sort algorithm from running a PL ordering.
bd3b77b
to
0ebde52
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, and yay for testing the complex member list sorting logic (fwiw I'd have probably split out the sorting algorithm and tested it independently of react / the component, but this is fine too).
The only reason I did it this way is it try and catch the result being wrong. The sorted list gets passed through several functions with the opportunity for mangling, so it seemed best to ensure the thing wasn't mangled wrongly. |
The previous algorithm had a bug where it was getting stuck on the power level comparison, leaving the memberlist incorrectly ordered. The new algorithm uses less branching to try and walk through the different cases instead. Additionally, the steps used to determine the order have changed slightly to better represent an active member list.
This change also includes changes to try and re-sort the member list more often during presence changes. Events are not always emitted, however. This may be a js-sdk bug but appears to happen prior to these changes as well.
Fixes element-hq/element-web#6953