2023-06-01 09:53:48 +02:00
|
|
|
/*
|
2024-09-09 14:57:16 +01:00
|
|
|
Copyright 2024 New Vector Ltd.
|
2023-06-01 09:53:48 +02:00
|
|
|
Copyright 2023 The Matrix.org Foundation C.I.C.
|
|
|
|
|
|
2025-01-06 11:18:54 +00:00
|
|
|
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
|
2024-09-09 14:57:16 +01:00
|
|
|
Please see LICENSE files in the repository root for full details.
|
2023-06-01 09:53:48 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import React from "react";
|
|
|
|
|
import classNames from "classnames";
|
2024-10-18 14:51:54 +01:00
|
|
|
import { ThreadsIcon } from "@vector-im/compound-design-tokens/assets/web/icons";
|
2023-06-01 09:53:48 +02:00
|
|
|
|
2026-03-04 18:40:12 +01:00
|
|
|
import { type MessagePreview } from "../../../stores/message-preview";
|
2025-02-05 13:25:06 +00:00
|
|
|
import { type Call } from "../../../models/Call";
|
2023-06-01 09:53:48 +02:00
|
|
|
import { RoomTileCallSummary } from "./RoomTileCallSummary";
|
|
|
|
|
|
|
|
|
|
interface Props {
|
|
|
|
|
call: Call | null;
|
|
|
|
|
messagePreview: MessagePreview | null;
|
|
|
|
|
roomId: string;
|
|
|
|
|
showMessagePreview: boolean;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const messagePreviewId = (roomId: string): string => `mx_RoomTile_messagePreview_${roomId}`;
|
|
|
|
|
|
2024-12-02 10:53:27 +00:00
|
|
|
export const RoomTileSubtitle: React.FC<Props> = ({ call, messagePreview, roomId, showMessagePreview }) => {
|
2023-06-01 09:53:48 +02:00
|
|
|
if (call) {
|
|
|
|
|
return (
|
|
|
|
|
<div className="mx_RoomTile_subtitle">
|
|
|
|
|
<RoomTileCallSummary call={call} />
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (showMessagePreview && messagePreview) {
|
|
|
|
|
const className = classNames("mx_RoomTile_subtitle", {
|
|
|
|
|
"mx_RoomTile_subtitle--thread-reply": messagePreview.isThreadReply,
|
|
|
|
|
});
|
|
|
|
|
|
2024-10-18 14:51:54 +01:00
|
|
|
const icon = messagePreview.isThreadReply ? <ThreadsIcon className="mx_Icon mx_Icon_12" /> : null;
|
2023-06-01 09:53:48 +02:00
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className={className} id={messagePreviewId(roomId)} title={messagePreview.text}>
|
|
|
|
|
{icon}
|
|
|
|
|
<span className="mx_RoomTile_subtitle_text">{messagePreview.text}</span>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
};
|