* feat: add video call and EC call to room list item vm * feat: add video call notification decoration to notification decoration component * feat: add video call support to room list item view * feat: add new RoomAvatarView component * feat: deprecate `DecoratedRoomAvatar` * feat: use `RoomAvatarView` in room list item * feat: allow custom class for `RoomAvatar` * test: update notification decoration * test: update room list item view * test: update room list snapshot * test: add tests for room avatar vm * test: add tests for room avatar view * test(e2e): update snapshots * fix: video room creation rights * test: e2e add test for public and video room
67 lines
2.5 KiB
TypeScript
67 lines
2.5 KiB
TypeScript
/*
|
|
* 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 HTMLProps, type JSX } from "react";
|
|
import MentionIcon from "@vector-im/compound-design-tokens/assets/web/icons/mention";
|
|
import ErrorIcon from "@vector-im/compound-design-tokens/assets/web/icons/error-solid";
|
|
import NotificationOffIcon from "@vector-im/compound-design-tokens/assets/web/icons/notifications-off-solid";
|
|
import VideoCallIcon from "@vector-im/compound-design-tokens/assets/web/icons/video-call-solid";
|
|
import { UnreadCounter, Unread } from "@vector-im/compound-web";
|
|
|
|
import { Flex } from "../../utils/Flex";
|
|
import { type RoomNotificationState } from "../../../stores/notifications/RoomNotificationState";
|
|
|
|
interface NotificationDecorationProps extends HTMLProps<HTMLDivElement> {
|
|
/**
|
|
* The notification state of the room or thread.
|
|
*/
|
|
notificationState: RoomNotificationState;
|
|
/**
|
|
* Whether the room has a video call.
|
|
*/
|
|
hasVideoCall: boolean;
|
|
}
|
|
|
|
/**
|
|
* Displays the notification decoration for a room or a thread.
|
|
*/
|
|
export function NotificationDecoration({
|
|
notificationState,
|
|
hasVideoCall,
|
|
...props
|
|
}: NotificationDecorationProps): JSX.Element | null {
|
|
const {
|
|
hasAnyNotificationOrActivity,
|
|
isUnsetMessage,
|
|
invited,
|
|
isMention,
|
|
isActivityNotification,
|
|
isNotification,
|
|
count,
|
|
muted,
|
|
} = notificationState;
|
|
if (!hasAnyNotificationOrActivity && !muted && !hasVideoCall) return null;
|
|
|
|
return (
|
|
<Flex
|
|
align="center"
|
|
justify="center"
|
|
gap="var(--cpd-space-1-5x)"
|
|
{...props}
|
|
data-testid="notification-decoration"
|
|
>
|
|
{isUnsetMessage && <ErrorIcon width="20px" height="20px" fill="var(--cpd-color-icon-critical-primary)" />}
|
|
{hasVideoCall && <VideoCallIcon width="20px" height="20px" fill="var(--cpd-color-icon-accent-primary)" />}
|
|
{invited && <UnreadCounter count={1} />}
|
|
{isMention && <MentionIcon width="20px" height="20px" fill="var(--cpd-color-icon-accent-primary)" />}
|
|
{(isMention || isNotification) && <UnreadCounter count={count || null} />}
|
|
{isActivityNotification && <Unread />}
|
|
{muted && <NotificationOffIcon width="20px" height="20px" fill="var(--cpd-color-icon-tertiary)" />}
|
|
</Flex>
|
|
);
|
|
}
|