Skip to content

Conversation

justjanne
Copy link
Contributor

@justjanne justjanne commented Sep 26, 2025

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

  • a deployment
  • docker images
    • v1.12.0 k8r.eu/justjanne/element-web:v1.12.0
    • develop k8r.eu/justjanne/element-web:develop
  • packages for Ubuntu and Windows (TODO)

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

@justjanne

This comment was marked as outdated.

@justjanne
Copy link
Contributor Author

image

@andybalaam
Copy link
Member

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 :-).

@justjanne

This comment was marked as resolved.

@justjanne justjanne force-pushed the labs/roomlist-sections branch from d7bb3cc to b1898d5 Compare September 29, 2025 15:59
@justjanne
Copy link
Contributor Author

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.

@justjanne
Copy link
Contributor Author

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",
Copy link
Contributor Author

@justjanne justjanne Sep 29, 2025

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;
Copy link
Contributor Author

@justjanne justjanne Sep 29, 2025

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 {
Copy link
Contributor Author

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 {
Copy link
Contributor Author

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.

@t3chguy t3chguy requested a review from a team October 1, 2025 11:08
@daniellekirkwood
Copy link
Contributor

Hi Janne! Thanks for the contribution, I'm taking a look into this. Thanks for your patience with me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-Enhancement Z-Community-PR Issue is solved by a community member's PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants