feat: exclude default section from room list item menu (#33278)

This commit is contained in:
Florian Duros 2026-04-27 11:32:05 +02:00 committed by GitHub
parent 4682f62e52
commit cb6c141580
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 12 deletions

View File

@ -427,8 +427,11 @@ export class RoomListItemViewModel
return (
RoomListStoreV3.instance.orderedSectionTags
// Exclude the Chats section because the user toggle the other sections to move rooms in and out of the Chats section.
.filter((tag) => tag !== CHATS_TAG)
// Exclude the Chats because the user toggle the other sections to move rooms in and out of the Chats section.
// Also exclude the default sections because they are available as toggles in the main context menu, and we don't want them to be duplicated in the "Move to section" submenu.
.filter(
(tag) => tag !== CHATS_TAG && tag !== DefaultTagID.Favourite && tag !== DefaultTagID.LowPriority,
)
.map((tag) => ({
tag,
name: RoomListItemViewModel.getSectionName(tag, customSectionData),

View File

@ -627,7 +627,7 @@ describe("RoomListItemViewModel", () => {
]);
});
it("should include sections from orderedSectionTags excluding CHATS_TAG", () => {
it("should include sections from orderedSectionTags excluding CHATS_TAG, favourite, and low priority", () => {
jest.spyOn(SettingsStore, "getValue").mockImplementation((setting) => {
if (setting === "feature_room_list_sections") return true;
return false;
@ -635,11 +635,11 @@ describe("RoomListItemViewModel", () => {
viewModel = new RoomListItemViewModel({ room, client: matrixClient });
const sections = viewModel.getSnapshot().sections;
expect(sections.map((s) => s.tag)).toEqual([DefaultTagID.Favourite, customTag, DefaultTagID.LowPriority]);
expect(sections.map((s) => s.tag)).toEqual([customTag]);
});
it("should mark the room current section as selected", () => {
room.tags = { [DefaultTagID.Favourite]: { order: 0 } };
room.tags = { [customTag]: { order: 0 } };
jest.spyOn(SettingsStore, "getValue").mockImplementation((setting) => {
if (setting === "feature_room_list_sections") return true;
return false;
@ -647,8 +647,7 @@ describe("RoomListItemViewModel", () => {
viewModel = new RoomListItemViewModel({ room, client: matrixClient });
const sections = viewModel.getSnapshot().sections;
expect(sections.find((s) => s.tag === DefaultTagID.Favourite)?.isSelected).toBe(true);
expect(sections.find((s) => s.tag === DefaultTagID.LowPriority)?.isSelected).toBe(false);
expect(sections.find((s) => s.tag === customTag)?.isSelected).toBe(true);
});
it("should use custom section name from CustomSectionData", () => {
@ -676,7 +675,7 @@ describe("RoomListItemViewModel", () => {
});
viewModel = new RoomListItemViewModel({ room, client: matrixClient });
expect(viewModel.getSnapshot().sections).toHaveLength(3); // Favourite, custom, LowPriority
expect(viewModel.getSnapshot().sections).toHaveLength(1);
// Simulate reordering: custom section removed
jest.spyOn(RoomListStoreV3.instance, "orderedSectionTags", "get").mockReturnValue([
@ -686,10 +685,7 @@ describe("RoomListItemViewModel", () => {
]);
watchCallback("RoomList.OrderedCustomSections", null, null as any, null, null);
expect(viewModel.getSnapshot().sections.map((s) => s.tag)).toEqual([
DefaultTagID.Favourite,
DefaultTagID.LowPriority,
]);
expect(viewModel.getSnapshot().sections.map((s) => s.tag)).toEqual([]);
});
});