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

This commit is contained in:
Florian Duros
2026-04-27 09:32:05 +00:00
committed by GitHub
parent 4682f62e52
commit cb6c141580
2 changed files with 11 additions and 12 deletions
@@ -427,8 +427,11 @@ export class RoomListItemViewModel
return ( return (
RoomListStoreV3.instance.orderedSectionTags RoomListStoreV3.instance.orderedSectionTags
// Exclude the Chats section because the user toggle the other sections to move rooms in and out of the Chats section. // Exclude the Chats because the user toggle the other sections to move rooms in and out of the Chats section.
.filter((tag) => tag !== CHATS_TAG) // 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) => ({ .map((tag) => ({
tag, tag,
name: RoomListItemViewModel.getSectionName(tag, customSectionData), name: RoomListItemViewModel.getSectionName(tag, customSectionData),
@@ -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) => { jest.spyOn(SettingsStore, "getValue").mockImplementation((setting) => {
if (setting === "feature_room_list_sections") return true; if (setting === "feature_room_list_sections") return true;
return false; return false;
@@ -635,11 +635,11 @@ describe("RoomListItemViewModel", () => {
viewModel = new RoomListItemViewModel({ room, client: matrixClient }); viewModel = new RoomListItemViewModel({ room, client: matrixClient });
const sections = viewModel.getSnapshot().sections; 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", () => { 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) => { jest.spyOn(SettingsStore, "getValue").mockImplementation((setting) => {
if (setting === "feature_room_list_sections") return true; if (setting === "feature_room_list_sections") return true;
return false; return false;
@@ -647,8 +647,7 @@ describe("RoomListItemViewModel", () => {
viewModel = new RoomListItemViewModel({ room, client: matrixClient }); viewModel = new RoomListItemViewModel({ room, client: matrixClient });
const sections = viewModel.getSnapshot().sections; const sections = viewModel.getSnapshot().sections;
expect(sections.find((s) => s.tag === DefaultTagID.Favourite)?.isSelected).toBe(true); expect(sections.find((s) => s.tag === customTag)?.isSelected).toBe(true);
expect(sections.find((s) => s.tag === DefaultTagID.LowPriority)?.isSelected).toBe(false);
}); });
it("should use custom section name from CustomSectionData", () => { it("should use custom section name from CustomSectionData", () => {
@@ -676,7 +675,7 @@ describe("RoomListItemViewModel", () => {
}); });
viewModel = new RoomListItemViewModel({ room, client: matrixClient }); 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 // Simulate reordering: custom section removed
jest.spyOn(RoomListStoreV3.instance, "orderedSectionTags", "get").mockReturnValue([ jest.spyOn(RoomListStoreV3.instance, "orderedSectionTags", "get").mockReturnValue([
@@ -686,10 +685,7 @@ describe("RoomListItemViewModel", () => {
]); ]);
watchCallback("RoomList.OrderedCustomSections", null, null as any, null, null); watchCallback("RoomList.OrderedCustomSections", null, null as any, null, null);
expect(viewModel.getSnapshot().sections.map((s) => s.tag)).toEqual([ expect(viewModel.getSnapshot().sections.map((s) => s.tag)).toEqual([]);
DefaultTagID.Favourite,
DefaultTagID.LowPriority,
]);
}); });
}); });