mirror of
https://github.com/vector-im/element-web.git
synced 2026-05-11 23:52:53 +02:00
Rename TextualEvent to TextualEventView
This commit is contained in:
parent
e8e50816f1
commit
2b366e82c5
@ -8,7 +8,7 @@ Please see LICENSE files in the repository root for full details.
|
||||
import React from "react";
|
||||
import { type Meta, type StoryFn } from "@storybook/react-vite";
|
||||
|
||||
import { TextualEvent as TextualEventComponent } from "./TextualEvent";
|
||||
import { TextualEventView as TextualEventComponent } from "./TextualEventView";
|
||||
import { MockViewModel } from "../../MockViewModel";
|
||||
|
||||
export default {
|
||||
@ -16,7 +16,7 @@ export default {
|
||||
component: TextualEventComponent,
|
||||
tags: ["autodocs"],
|
||||
args: {
|
||||
vm: new MockViewModel("Dummy textual event text"),
|
||||
vm: new MockViewModel({ content: "Dummy textual event text" }),
|
||||
},
|
||||
} as Meta<typeof TextualEventComponent>;
|
||||
|
||||
@ -9,11 +9,11 @@ import { composeStories } from "@storybook/react-vite";
|
||||
import { render } from "jest-matrix-react";
|
||||
import React from "react";
|
||||
|
||||
import * as stories from "./TextualEvent.stories.tsx";
|
||||
import * as stories from "./TextualEventView.stories.tsx";
|
||||
|
||||
const { Default } = composeStories(stories);
|
||||
|
||||
describe("TextualEvent", () => {
|
||||
describe("TextualEventView", () => {
|
||||
it("renders a textual event", () => {
|
||||
const { container } = render(<Default />);
|
||||
expect(container).toMatchSnapshot();
|
||||
@ -10,14 +10,15 @@ import React, { type ReactNode, type JSX } from "react";
|
||||
import { type ViewModel } from "../../ViewModel";
|
||||
import { useViewModel } from "../../useViewModel";
|
||||
|
||||
export type TextualEventViewSnapshot = string | ReactNode;
|
||||
export type TextualEventViewSnapshot = {
|
||||
content: string | ReactNode;
|
||||
};
|
||||
|
||||
export interface Props {
|
||||
vm: ViewModel<TextualEventViewSnapshot>;
|
||||
}
|
||||
|
||||
export function TextualEvent({ vm }: Props): JSX.Element {
|
||||
const contents = useViewModel(vm);
|
||||
|
||||
return <div className="mx_TextualEvent">{contents}</div>;
|
||||
export function TextualEventView({ vm }: Props): JSX.Element {
|
||||
const snapshot = useViewModel(vm);
|
||||
return <div className="mx_TextualEvent">{snapshot.content}</div>;
|
||||
}
|
||||
@ -5,4 +5,4 @@ SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Com
|
||||
Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
|
||||
export { TextualEvent } from "./TextualEvent";
|
||||
export { TextualEventView } from "./TextualEventView";
|
||||
|
||||
@ -10,18 +10,18 @@ import { MatrixEventEvent } from "matrix-js-sdk/src/matrix";
|
||||
import { type EventTileTypeProps } from "../../events/EventTileFactory";
|
||||
import { MatrixClientPeg } from "../../MatrixClientPeg";
|
||||
import { textForEvent } from "../../TextForEvent";
|
||||
import { type TextualEventViewSnapshot } from "../../shared-components/event-tiles/TextualEvent/TextualEvent";
|
||||
import { type TextualEventViewSnapshot } from "../../shared-components/event-tiles/TextualEvent/TextualEventView";
|
||||
import { BaseViewModel } from "../base/BaseViewModel";
|
||||
|
||||
export class TextualEventViewModel extends BaseViewModel<TextualEventViewSnapshot, EventTileTypeProps> {
|
||||
public constructor(props: EventTileTypeProps) {
|
||||
super(props, "");
|
||||
super(props, { content: "" });
|
||||
this.setTextFromEvent();
|
||||
}
|
||||
|
||||
private setTextFromEvent = (): void => {
|
||||
const text = textForEvent(this.props.mxEvent, MatrixClientPeg.safeGet(), true, this.props.showHiddenEvents);
|
||||
this.snapshot.set(text);
|
||||
const content = textForEvent(this.props.mxEvent, MatrixClientPeg.safeGet(), true, this.props.showHiddenEvents);
|
||||
this.snapshot.set({ content });
|
||||
};
|
||||
|
||||
protected addDownstreamSubscription = (): void => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user