2019-10-13 15:08:50 +03:00
|
|
|
/*
|
2024-09-09 14:57:16 +01:00
|
|
|
Copyright 2024 New Vector Ltd.
|
|
|
|
|
Copyright 2020, 2021 Tulir Asokan <tulir@maunium.net>
|
2019-10-13 15:08:50 +03:00
|
|
|
|
2024-09-09 14:57:16 +01:00
|
|
|
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only
|
|
|
|
|
Please see LICENSE files in the repository root for full details.
|
2019-10-13 15:08:50 +03:00
|
|
|
*/
|
|
|
|
|
|
2020-04-10 15:45:59 +03:00
|
|
|
import React from "react";
|
2024-03-11 09:30:00 +00:00
|
|
|
import { ImageContent } from "matrix-js-sdk/src/types";
|
2021-10-22 17:23:32 -05:00
|
|
|
|
2021-07-13 08:46:45 +02:00
|
|
|
import MImageBody from "./MImageBody";
|
2019-10-13 15:08:50 +03:00
|
|
|
|
2021-07-14 09:53:40 +02:00
|
|
|
const FORCED_IMAGE_HEIGHT = 44;
|
|
|
|
|
|
2019-10-13 15:08:50 +03:00
|
|
|
export default class MImageReplyBody extends MImageBody {
|
2021-07-02 14:17:40 +02:00
|
|
|
public onClick = (ev: React.MouseEvent): void => {
|
|
|
|
|
ev.preventDefault();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public wrapImage(contentUrl: string, children: JSX.Element): JSX.Element {
|
2019-10-13 15:08:50 +03:00
|
|
|
return children;
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-13 17:01:43 +00:00
|
|
|
public render(): React.ReactNode {
|
2022-03-25 16:31:40 +00:00
|
|
|
if (this.state.error) {
|
2020-04-10 15:45:59 +03:00
|
|
|
return super.render();
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-17 13:07:58 +01:00
|
|
|
const content = this.props.mxEvent.getContent<ImageContent>();
|
2023-03-29 08:22:35 +01:00
|
|
|
const thumbnail = this.state.contentUrl
|
|
|
|
|
? this.messageContent(this.state.contentUrl, this.state.thumbUrl, content, FORCED_IMAGE_HEIGHT)
|
|
|
|
|
: undefined;
|
2020-04-10 15:45:59 +03:00
|
|
|
|
|
|
|
|
return <div className="mx_MImageReplyBody">{thumbnail}</div>;
|
2019-10-13 15:08:50 +03:00
|
|
|
}
|
|
|
|
|
}
|