2018-08-20 15:20:59 +00:00
|
|
|
/*
|
|
|
|
Copyright 2018 New Vector Ltd
|
|
|
|
|
|
|
|
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';
|
2019-09-06 17:37:43 +00:00
|
|
|
import createReactClass from 'create-react-class';
|
2018-08-20 15:20:59 +00:00
|
|
|
|
|
|
|
import dis from '../../../dispatcher';
|
2019-10-01 02:39:58 +00:00
|
|
|
import { RoomPermalinkCreator } from '../../../utils/permalinks/Permalinks';
|
2018-08-20 15:20:59 +00:00
|
|
|
import { _t } from '../../../languageHandler';
|
2019-02-25 15:15:42 +00:00
|
|
|
import MatrixClientPeg from '../../../MatrixClientPeg';
|
2018-08-20 15:20:59 +00:00
|
|
|
|
2019-09-06 17:37:43 +00:00
|
|
|
module.exports = createReactClass({
|
2018-08-20 15:20:59 +00:00
|
|
|
displayName: 'RoomCreate',
|
|
|
|
|
|
|
|
propTypes: {
|
|
|
|
/* the MatrixEvent to show */
|
|
|
|
mxEvent: PropTypes.object.isRequired,
|
|
|
|
},
|
|
|
|
|
|
|
|
_onLinkClicked: function(e) {
|
|
|
|
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'],
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
render: function() {
|
|
|
|
const predecessor = this.props.mxEvent.getContent()['predecessor'];
|
|
|
|
if (predecessor === undefined) {
|
|
|
|
return <div />; // We should never have been instaniated in this case
|
|
|
|
}
|
2019-02-25 15:15:42 +00:00
|
|
|
const prevRoom = MatrixClientPeg.get().getRoom(predecessor['room_id']);
|
2019-05-13 20:12:58 +00:00
|
|
|
const permalinkCreator = new RoomPermalinkCreator(prevRoom, predecessor['room_id']);
|
2019-02-25 15:15:42 +00:00
|
|
|
permalinkCreator.load();
|
|
|
|
const predecessorPermalink = permalinkCreator.forEvent(predecessor['event_id']);
|
2018-08-20 15:20:59 +00:00
|
|
|
return <div className="mx_CreateEvent">
|
2019-03-02 00:21:37 +00:00
|
|
|
<div className="mx_CreateEvent_image" />
|
2018-08-20 15:20:59 +00:00
|
|
|
<div className="mx_CreateEvent_header">
|
|
|
|
{_t("This room is a continuation of another conversation.")}
|
|
|
|
</div>
|
|
|
|
<a className="mx_CreateEvent_link"
|
2019-02-25 15:15:42 +00:00
|
|
|
href={predecessorPermalink}
|
2018-08-20 15:20:59 +00:00
|
|
|
onClick={this._onLinkClicked}
|
|
|
|
>
|
|
|
|
{_t("Click here to see older messages.")}
|
|
|
|
</a>
|
|
|
|
</div>;
|
|
|
|
},
|
|
|
|
});
|