2017-12-10 12:50:41 +00:00
|
|
|
/*
|
2021-07-13 18:35:56 -06:00
|
|
|
Copyright 2017 - 2021 The Matrix.org Foundation C.I.C.
|
2017-12-10 12:50:41 +00: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.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import React from 'react';
|
2021-10-22 17:23:32 -05:00
|
|
|
import { MatrixEvent } from 'matrix-js-sdk/src/models/event';
|
|
|
|
|
|
2020-05-13 20:41:41 -06:00
|
|
|
import dis from '../../../dispatcher/dispatcher';
|
2017-12-15 17:57:24 +00:00
|
|
|
import { _t } from '../../../languageHandler';
|
2021-06-29 13:11:58 +01:00
|
|
|
import { RoomPermalinkCreator } from "../../../utils/permalinks/Permalinks";
|
2021-07-13 08:45:36 +02:00
|
|
|
import ReplyTile from './ReplyTile';
|
2021-10-19 16:05:34 +01:00
|
|
|
import RoomContext, { TimelineRenderingType } from '../../../contexts/RoomContext';
|
2022-06-27 09:43:58 +01:00
|
|
|
import AccessibleButton from "../elements/AccessibleButton";
|
2017-12-10 12:50:41 +00:00
|
|
|
|
2021-10-19 16:05:34 +01:00
|
|
|
function cancelQuoting(context: TimelineRenderingType) {
|
2017-12-10 12:50:41 +00:00
|
|
|
dis.dispatch({
|
2018-02-19 23:41:07 +00:00
|
|
|
action: 'reply_to_event',
|
2017-12-10 12:50:41 +00:00
|
|
|
event: null,
|
2021-10-19 16:05:34 +01:00
|
|
|
context,
|
2017-12-10 12:50:41 +00:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-17 15:09:13 +02:00
|
|
|
interface IProps {
|
2021-07-17 15:29:18 +02:00
|
|
|
permalinkCreator: RoomPermalinkCreator;
|
2021-10-19 16:05:34 +01:00
|
|
|
replyToEvent: MatrixEvent;
|
2021-07-17 15:09:13 +02:00
|
|
|
}
|
|
|
|
|
|
2021-10-19 16:05:34 +01:00
|
|
|
export default class ReplyPreview extends React.Component<IProps> {
|
|
|
|
|
public static contextType = RoomContext;
|
2019-03-01 09:36:36 +00:00
|
|
|
|
2021-10-19 16:05:34 +01:00
|
|
|
public render(): JSX.Element {
|
|
|
|
|
if (!this.props.replyToEvent) return null;
|
2017-12-10 12:50:41 +00:00
|
|
|
|
2018-02-10 12:38:25 +00:00
|
|
|
return <div className="mx_ReplyPreview">
|
2022-06-27 09:43:58 +01:00
|
|
|
<div className="mx_ReplyPreview_section">
|
|
|
|
|
<div className="mx_ReplyPreview_header">
|
|
|
|
|
<span>{ _t('Replying') }</span>
|
|
|
|
|
<AccessibleButton
|
|
|
|
|
className="mx_ReplyPreview_header_cancel"
|
|
|
|
|
onClick={() => cancelQuoting(this.context.timelineRenderingType)}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
<ReplyTile
|
|
|
|
|
mxEvent={this.props.replyToEvent}
|
|
|
|
|
permalinkCreator={this.props.permalinkCreator}
|
|
|
|
|
/>
|
2017-12-10 12:50:41 +00:00
|
|
|
</div>
|
|
|
|
|
</div>;
|
|
|
|
|
}
|
|
|
|
|
}
|