2018-08-20 18:20:59 +03:00
|
|
|
/*
|
|
|
|
Copyright 2018 New Vector Ltd
|
2019-12-20 03:45:24 +03:00
|
|
|
Copyright 2019 The Matrix.org Foundation C.I.C.
|
2018-08-20 18:20:59 +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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
|
2020-05-14 05:41:41 +03:00
|
|
|
import dis from '../../../dispatcher/dispatcher';
|
2019-10-01 05:39:58 +03:00
|
|
|
import { RoomPermalinkCreator } from '../../../utils/permalinks/Permalinks';
|
2018-08-20 18:20:59 +03:00
|
|
|
import { _t } from '../../../languageHandler';
|
2019-12-21 00:13:46 +03:00
|
|
|
import {MatrixClientPeg} from '../../../MatrixClientPeg';
|
2020-11-04 20:00:07 +03:00
|
|
|
import EventTileBubble from "./EventTileBubble";
|
2018-08-20 18:20:59 +03:00
|
|
|
|
2020-08-29 14:14:16 +03:00
|
|
|
export default class RoomCreate extends React.Component {
|
|
|
|
static propTypes = {
|
2018-08-20 18:20:59 +03:00
|
|
|
/* the MatrixEvent to show */
|
|
|
|
mxEvent: PropTypes.object.isRequired,
|
2020-08-29 14:14:16 +03:00
|
|
|
};
|
2018-08-20 18:20:59 +03:00
|
|
|
|
2020-08-29 14:14:16 +03:00
|
|
|
_onLinkClicked = e => {
|
2018-08-20 18:20:59 +03:00
|
|
|
e.preventDefault();
|
|
|
|
|
|
|
|
const predecessor = this.props.mxEvent.getContent()['predecessor'];
|
|
|
|
|
|
|
|
dis.dispatch({
|
|
|
|
action: 'view_room',
|
|
|
|
event_id: predecessor['event_id'],
|
|
|
|
highlighted: true,
|
|
|
|
room_id: predecessor['room_id'],
|
|
|
|
});
|
2020-08-29 14:14:16 +03:00
|
|
|
};
|
2018-08-20 18:20:59 +03:00
|
|
|
|
2020-08-29 14:14:16 +03:00
|
|
|
render() {
|
2018-08-20 18:20:59 +03:00
|
|
|
const predecessor = this.props.mxEvent.getContent()['predecessor'];
|
|
|
|
if (predecessor === undefined) {
|
2020-10-14 11:46:54 +03:00
|
|
|
return <div />; // We should never have been instantiated in this case
|
2018-08-20 18:20:59 +03:00
|
|
|
}
|
2019-02-25 18:15:42 +03:00
|
|
|
const prevRoom = MatrixClientPeg.get().getRoom(predecessor['room_id']);
|
2019-05-13 23:12:58 +03:00
|
|
|
const permalinkCreator = new RoomPermalinkCreator(prevRoom, predecessor['room_id']);
|
2019-02-25 18:15:42 +03:00
|
|
|
permalinkCreator.load();
|
|
|
|
const predecessorPermalink = permalinkCreator.forEvent(predecessor['event_id']);
|
2020-11-04 20:00:07 +03:00
|
|
|
const link = (
|
|
|
|
<a href={predecessorPermalink} onClick={this._onLinkClicked}>
|
2018-08-20 18:20:59 +03:00
|
|
|
{_t("Click here to see older messages.")}
|
|
|
|
</a>
|
2020-11-04 20:00:07 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
return <EventTileBubble
|
|
|
|
className="mx_CreateEvent"
|
|
|
|
title={_t("This room is a continuation of another conversation.")}
|
|
|
|
subtitle={link}
|
|
|
|
/>;
|
2020-08-29 14:14:16 +03:00
|
|
|
}
|
|
|
|
}
|