Skip to content

Commit 50d355d

Browse files
committed
feat: exclude default section from room list item menu
1 parent 8f9953f commit 50d355d

2 files changed

Lines changed: 11 additions & 12 deletions

File tree

apps/web/src/viewmodels/room-list/RoomListItemViewModel.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -423,8 +423,11 @@ export class RoomListItemViewModel
423423

424424
return (
425425
RoomListStoreV3.instance.orderedSectionTags
426-
// Exclude the Chats section because the user toggle the other sections to move rooms in and out of the Chats section.
427-
.filter((tag) => tag !== CHATS_TAG)
426+
// Exclude the Chats because the user toggle the other sections to move rooms in and out of the Chats section.
427+
// 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.
428+
.filter(
429+
(tag) => tag !== CHATS_TAG && tag !== DefaultTagID.Favourite && tag !== DefaultTagID.LowPriority,
430+
)
428431
.map((tag) => ({
429432
tag,
430433
name: RoomListItemViewModel.getSectionName(tag, customSectionData),

apps/web/test/viewmodels/room-list/RoomListItemViewModel-test.tsx

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -620,28 +620,27 @@ describe("RoomListItemViewModel", () => {
620620
]);
621621
});
622622

623-
it("should include sections from orderedSectionTags excluding CHATS_TAG", () => {
623+
it("should include sections from orderedSectionTags excluding CHATS_TAG, favourite, and low priority", () => {
624624
jest.spyOn(SettingsStore, "getValue").mockImplementation((setting) => {
625625
if (setting === "feature_room_list_sections") return true;
626626
return false;
627627
});
628628
viewModel = new RoomListItemViewModel({ room, client: matrixClient });
629629

630630
const sections = viewModel.getSnapshot().sections;
631-
expect(sections.map((s) => s.tag)).toEqual([DefaultTagID.Favourite, customTag, DefaultTagID.LowPriority]);
631+
expect(sections.map((s) => s.tag)).toEqual([customTag]);
632632
});
633633

634634
it("should mark the room current section as selected", () => {
635-
room.tags = { [DefaultTagID.Favourite]: { order: 0 } };
635+
room.tags = { [customTag]: { order: 0 } };
636636
jest.spyOn(SettingsStore, "getValue").mockImplementation((setting) => {
637637
if (setting === "feature_room_list_sections") return true;
638638
return false;
639639
});
640640
viewModel = new RoomListItemViewModel({ room, client: matrixClient });
641641

642642
const sections = viewModel.getSnapshot().sections;
643-
expect(sections.find((s) => s.tag === DefaultTagID.Favourite)?.isSelected).toBe(true);
644-
expect(sections.find((s) => s.tag === DefaultTagID.LowPriority)?.isSelected).toBe(false);
643+
expect(sections.find((s) => s.tag === customTag)?.isSelected).toBe(true);
645644
});
646645

647646
it("should use custom section name from CustomSectionData", () => {
@@ -669,7 +668,7 @@ describe("RoomListItemViewModel", () => {
669668
});
670669

671670
viewModel = new RoomListItemViewModel({ room, client: matrixClient });
672-
expect(viewModel.getSnapshot().sections).toHaveLength(3); // Favourite, custom, LowPriority
671+
expect(viewModel.getSnapshot().sections).toHaveLength(1);
673672

674673
// Simulate reordering: custom section removed
675674
jest.spyOn(RoomListStoreV3.instance, "orderedSectionTags", "get").mockReturnValue([
@@ -679,10 +678,7 @@ describe("RoomListItemViewModel", () => {
679678
]);
680679
watchCallback("RoomList.OrderedCustomSections", null, null as any, null, null);
681680

682-
expect(viewModel.getSnapshot().sections.map((s) => s.tag)).toEqual([
683-
DefaultTagID.Favourite,
684-
DefaultTagID.LowPriority,
685-
]);
681+
expect(viewModel.getSnapshot().sections.map((s) => s.tag)).toEqual([]);
686682
});
687683
});
688684

0 commit comments

Comments
 (0)