Low priority menu item should be a toggle (#30071)

* Use toggle on low priority menu item

* Fix broken tests
This commit is contained in:
R Midhun Suresh
2025-06-04 23:21:58 +05:30
committed by GitHub
parent 231ab20dcf
commit 2b1a4e007c
4 changed files with 10 additions and 3 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 79 KiB

After

Width:  |  Height:  |  Size: 80 KiB

View File

@@ -37,6 +37,10 @@ export interface RoomListItemMenuViewState {
* Whether the room is a favourite room. * Whether the room is a favourite room.
*/ */
isFavourite: boolean; isFavourite: boolean;
/**
* Whether the room is a low priority room.
*/
isLowPriority: boolean;
/** /**
* Can invite other user's in the room. * Can invite other user's in the room.
*/ */
@@ -117,6 +121,7 @@ export function useRoomListItemMenuViewModel(room: Room): RoomListItemMenuViewSt
const isDm = Boolean(DMRoomMap.shared().getUserIdForRoomId(room.roomId)); const isDm = Boolean(DMRoomMap.shared().getUserIdForRoomId(room.roomId));
const isFavourite = Boolean(roomTags[DefaultTagID.Favourite]); const isFavourite = Boolean(roomTags[DefaultTagID.Favourite]);
const isLowPriority = Boolean(roomTags[DefaultTagID.LowPriority]);
const isArchived = Boolean(roomTags[DefaultTagID.Archived]); const isArchived = Boolean(roomTags[DefaultTagID.Archived]);
const showMoreOptionsMenu = hasAccessToOptionsMenu(room); const showMoreOptionsMenu = hasAccessToOptionsMenu(room);
@@ -200,6 +205,7 @@ export function useRoomListItemMenuViewModel(room: Room): RoomListItemMenuViewSt
showMoreOptionsMenu, showMoreOptionsMenu,
showNotificationMenu, showNotificationMenu,
isFavourite, isFavourite,
isLowPriority,
canInvite, canInvite,
canCopyRoomLink, canCopyRoomLink,
canMarkAsRead, canMarkAsRead,

View File

@@ -109,12 +109,12 @@ function MoreOptionsMenu({ vm, setMenuOpen }: MoreOptionsMenuProps): JSX.Element
onSelect={vm.toggleFavorite} onSelect={vm.toggleFavorite}
onClick={(evt) => evt.stopPropagation()} onClick={(evt) => evt.stopPropagation()}
/> />
<MenuItem <ToggleMenuItem
checked={vm.isLowPriority}
Icon={ArrowDownIcon} Icon={ArrowDownIcon}
label={_t("room_list|more_options|low_priority")} label={_t("room_list|more_options|low_priority")}
onSelect={vm.toggleLowPriority} onSelect={vm.toggleLowPriority}
onClick={(evt) => evt.stopPropagation()} onClick={(evt) => evt.stopPropagation()}
hideChevron={true}
/> />
{vm.canInvite && ( {vm.canInvite && (
<MenuItem <MenuItem

View File

@@ -28,6 +28,7 @@ describe("<RoomListItemMenuView />", () => {
showMoreOptionsMenu: true, showMoreOptionsMenu: true,
showNotificationMenu: true, showNotificationMenu: true,
isFavourite: true, isFavourite: true,
isLowPriority: true,
canInvite: true, canInvite: true,
canMarkAsUnread: true, canMarkAsUnread: true,
canMarkAsRead: true, canMarkAsRead: true,
@@ -114,7 +115,7 @@ describe("<RoomListItemMenuView />", () => {
expect(defaultValue.toggleFavorite).toHaveBeenCalled(); expect(defaultValue.toggleFavorite).toHaveBeenCalled();
await user.click(openMenu); await user.click(openMenu);
await user.click(screen.getByRole("menuitem", { name: "Low priority" })); await user.click(screen.getByRole("menuitemcheckbox", { name: "Low priority" }));
expect(defaultValue.toggleLowPriority).toHaveBeenCalled(); expect(defaultValue.toggleLowPriority).toHaveBeenCalled();
await user.click(openMenu); await user.click(openMenu);