-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Reintroduce section sorting to the roomlist #30887
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
base: develop
Are you sure you want to change the base?
Conversation
77a1f19
to
054eff7
Compare
dfebcfe
to
438dfd2
Compare
438dfd2
to
77a7960
Compare
77a7960
to
cf86efe
Compare
cf86efe
to
2a1c74b
Compare
This comment was marked as outdated.
This comment was marked as outdated.
8382cfc
to
f9b6eeb
Compare
f9b6eeb
to
d7bb3cc
Compare
I've been trying this out today and it seems a real improvement. For me to be able to use this instead of my current hack, I'd just need "unread" to mean "unread" i.e. rooms with a dot instead of whatever it means now :-). |
This comment was marked as resolved.
This comment was marked as resolved.
d7bb3cc
to
b1898d5
Compare
The conclusion of the investigation regarding the unread filter is that we'll stick with the current implementation, which uses the Unread filter of the new room list. |
I've decided not to implement section headers for now, to unblock the rest of this PR for now. |
"sort_by": "Sort by", | ||
"sort_by_activity": "Activity", | ||
"sort_by_alphabet": "A-Z", | ||
"sort_sections": "Group rooms by type", |
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.
Feel free to suggest a better alternative, as long as we don't have section headers, "Sort rooms by type" might make more sense anyway.
* A string that uniquely identifies this given sorter. | ||
*/ | ||
type: SortingAlgorithm; | ||
type: string; |
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.
As this is used by the RoomList and RoomSkipList to determine whether the sorter has changed – basically like a hash over the sorter's properties – this must uniquely identify all properties of the current sorter.
Therefore I had to change it to string, to be able to represent the added properties of the SectionSorter.
import type { Sorter } from "."; | ||
import { buildSections, type Section, sectionMatches } from "../sections"; | ||
|
||
export class SectionSorter implements Sorter { |
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.
Basically, this sorter uses roomlist filters to group rooms into sections, and then uses another sorter within each section.
A room is considered part of a section if it matches ALL filters of that section. If a room matches no other section, it is sorted into the null section.
[FilterKey.LowPriorityFilter]: new LowPriorityFilter(), | ||
}; | ||
|
||
export function sectionMatches(section: Section, room: Room): boolean { |
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.
A room matches a section if it matches every filter of that section. The null/"Other" section matches no room, it is handled separately to allow other sections to appear after it.
Hi Janne! Thanks for the contribution, I'm taking a look into this. Thanks for your patience with me! |
In Short
This PR allows sorting the room list into sections, similar to the functionality of the old room list.
Until this gets merged, I'll maintain
k8r.eu/justjanne/element-web:v1.12.0
k8r.eu/justjanne/element-web:develop
Rationale
Many group chat apps section their room list, e.g. Slack with Rooms and DMs, Discord with Rooms and Voice/Video rooms. As I heavily rely on this feature every day, I decided to port it.
Limitations
This will not allow custom sorting methods per section, nor collapsible sections. All it does is change the sorting order to sort certain sections first. I'm planning to add section headers as well, but I haven't fully brainstormed how that'd work yet.
Checklist
public
/exported
symbols have accurate TSDoc documentation.