Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Change the room list algo to eagerly delete and carefully insert #2701

Merged
merged 3 commits into from
Feb 26, 2019

Conversation

turt2live
Copy link
Member

@turt2live turt2live commented Feb 25, 2019

Fixes element-hq/element-web#8898 (in the most complicated way possible: a rewrite)

Note to the reviewer: It may be easier to understand this by making use of github's split diff view (dropdown next to 'Review Changes' on the Files tab). Also, feel free to merge this if it is satisfactory.

Previously it made some complicated assumptions about the contexts it was called in (it generally assumed it just had to shuffle rooms between tags and didn't really handle new rooms very well).

The algorithm now eagerly tries to drop rooms from tags and carefully inserts them. The actual insertion logic is mostly untouched: the only part changed is how it handles failure to insert into tag. It shouldn't be possible for this algorithm to completely skip a room unless the tag is empty, so we special case that.

There are several TODO comments to be addressed here. Namely, it doesn't handle manually ordered tags (favourites, custom, etc) and doesn't check if tags are even enabled. Changes in this area are waiting for #2686 to land to take advantage of monitoring the settings flag for tags.

Previously it made some complicated assumptions about the contexts it was called in (it generally assumed it just had to shuffle rooms between tags and didn't really handle new rooms very well).

The algorithm now eagerly tries to drop rooms from tags and carefully inserts them. The actual insertion logic is mostly untouched: the only part changed is how it handles failure to insert into tag. It shouldn't be possible for this algorithm to completely skip a room unless the tag is empty, so we special case that.

There are several TODO comments to be addressed here. Namely, it doesn't handle manually ordered tags (favourites, custom, etc) and doesn't check if tags are even enabled. Changes in this area are waiting for #2686 to land to take advantage of monitoring the settings flag for tags.
@turt2live turt2live removed the blocked label Feb 25, 2019
@@ -52,7 +52,6 @@ export default class AccountSettingsHandler extends MatrixClientBackedSettingsHa
} else if (event.getType() === "im.vector.web.settings") {
// We can't really discern what changed, so trigger updates for everything
for (const settingName of Object.keys(event.getContent())) {
console.log(settingName);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was left behind in a previous PR

@turt2live turt2live marked this pull request as ready for review February 25, 2019 20:47
@turt2live turt2live requested a review from a team February 25, 2019 20:47
@turt2live
Copy link
Member Author

Tests for this are reserved for element-hq/element-web#8922

@turt2live turt2live removed their assignment Feb 26, 2019
@bwindels bwindels self-assigned this Feb 26, 2019
Copy link
Contributor

@bwindels bwindels left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think I have the mental energy to fully grasp the changes in the PR, but you've seem to have put quite some thought into this, and we have time to fix potential issues until this lands in production, so I am OK to merge this. Sorry for not being more thorough, but it's late in the day, and as discussed before, I find the code somewhat hard to comprehend.

@@ -64,7 +64,7 @@ class RoomListStore extends Store {
* behave.
* @param {boolean} forceRegeneration True to force a change in the algorithm
*/
updateSortingAlgorithm(forceRegeneration=false) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just an suggestion, but I feel like this flag could be a future source of bugs and misunderstanding. As this method doesn't seem to be on any hotpath, how about always regenerating?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not really on a hot path, but it is a bit of a waste of cycles to regenerate the list from scratch whenever a setting at a lower level changes. Fixing the setting monitors to not spam changes would also fix this, which is next up on my list.

@turt2live
Copy link
Member Author

Sorry this is so complex :(

I really want to fix it to not be difficult - I hope to do this after the release.

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

Successfully merging this pull request may close these issues.

2 participants