mirror of
https://github.com/Novaloop-AG/healthchat-web.git
synced 2026-12-05 11:38:00 +00:00
4f3a1a2cc6
* refactoring and creation of shared-components for reductedBodyView * move redacted message rendering to shared MVVM view * Update snapshots + fix lint errors * Remove MatrixClientPeg and use reguler react matrix client context * Stop resyncing redacted body view models with mxEvent * Fix redacted_because test fixtures for stricter event typing * Simplify redacted body client access * Watch timestamp setting in redacted body view model * Refactor redacted and decryption failure body factories into MBodyFactory * Prettier Fix * Refactor FileBody into same pattern for consitancy
61 lines
1.7 KiB
TypeScript
61 lines
1.7 KiB
TypeScript
/*
|
|
* Copyright 2026 Element Creations 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, type Ref } from "react";
|
|
import classNames from "classnames";
|
|
import { DeleteIcon } from "@vector-im/compound-design-tokens/assets/web/icons";
|
|
import { Tooltip } from "@vector-im/compound-web";
|
|
|
|
import { type ViewModel } from "../../viewmodel";
|
|
import { useViewModel } from "../../viewmodel/useViewModel";
|
|
import styles from "./RedactedBodyView.module.css";
|
|
|
|
export interface RedactedBodyViewSnapshot {
|
|
/**
|
|
* Localized redaction message content.
|
|
*/
|
|
text: string;
|
|
/**
|
|
* Optional localized tooltip shown with the redaction timestamp.
|
|
*/
|
|
tooltip?: string;
|
|
}
|
|
|
|
export type RedactedBodyViewModel = ViewModel<RedactedBodyViewSnapshot>;
|
|
|
|
interface RedactedBodyViewProps {
|
|
/**
|
|
* ViewModel providing the rendered text and tooltip.
|
|
*/
|
|
vm: RedactedBodyViewModel;
|
|
/**
|
|
* Optional CSS class name applied to the root span.
|
|
*/
|
|
className?: string;
|
|
/**
|
|
* Optional ref forwarded to the root span.
|
|
*/
|
|
ref?: Ref<HTMLSpanElement>;
|
|
}
|
|
|
|
export function RedactedBodyView({ vm, className, ref }: Readonly<RedactedBodyViewProps>): JSX.Element {
|
|
const { text, tooltip } = useViewModel(vm);
|
|
|
|
const content = (
|
|
<span className={classNames(styles.content, className)} ref={ref}>
|
|
<DeleteIcon className={styles.icon} aria-hidden="true" />
|
|
<span>{text}</span>
|
|
</span>
|
|
);
|
|
|
|
if (!tooltip) {
|
|
return content;
|
|
}
|
|
|
|
return <Tooltip description={tooltip}>{content}</Tooltip>;
|
|
}
|