2019-10-13 15:08:50 +03:00
|
|
|
/*
|
2021-05-01 16:11:30 +03:00
|
|
|
Copyright 2020-2021 Tulir Asokan <tulir@maunium.net>
|
2019-10-13 15:08:50 +03:00
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
|
limitations under the License.
|
|
|
|
|
*/
|
|
|
|
|
|
2020-04-10 15:45:59 +03:00
|
|
|
import React from "react";
|
2021-10-22 17:23:32 -05:00
|
|
|
|
2021-07-13 08:46:45 +02:00
|
|
|
import MImageBody from "./MImageBody";
|
2021-07-02 14:17:40 +02:00
|
|
|
import { IMediaEventContent } from "../../../customisations/models/IMediaEventContent";
|
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();
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-13 08:47:37 +02:00
|
|
|
const content = this.props.mxEvent.getContent<IMediaEventContent>();
|
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
|
|
|
}
|
|
|
|
|
}
|