/* * Copyright 2025 New Vector Ltd. * * SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial * Please see LICENSE files in the repository root for full details. */ import React, { type JSX, useState } from "react"; import { type Room } from "matrix-js-sdk/src/matrix"; import classNames from "classnames"; import { useRoomListItemViewModel } from "../../../viewmodels/roomlist/RoomListItemViewModel"; import { Flex } from "../../../utils/Flex"; import { RoomListItemMenuView } from "./RoomListItemMenuView"; import { NotificationDecoration } from "../NotificationDecoration"; import { RoomAvatarView } from "../../avatars/RoomAvatarView"; interface RoomListItemViewPropsProps extends React.HTMLAttributes { /** * The room to display */ room: Room; /** * Whether the room is selected */ isSelected: boolean; } /** * An item in the room list */ export function RoomListItemView({ room, isSelected, ...props }: RoomListItemViewPropsProps): JSX.Element { const vm = useRoomListItemViewModel(room); const [isHover, setIsHover] = useState(false); const [isMenuOpen, setIsMenuOpen] = useState(false); // The compound menu in RoomListItemMenuView needs to be rendered when the hover menu is shown // Using display: none; and then display:flex when hovered in CSS causes the menu to be misaligned const showHoverDecoration = (isMenuOpen || isHover) && vm.showHoverMenu; const isNotificationDecorationVisible = !showHoverDecoration && (vm.notificationState.hasAnyNotificationOrActivity || vm.notificationState.muted || vm.hasParticipantInCall); return ( ); }