Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 7f2599c

Browse files
authored
Merge pull request #2123 from matrix-org/dbkr/roomcreate
Support room creation events
2 parents 499d14c + 6cbe414 commit 7f2599c

File tree

6 files changed

+116
-1
lines changed

6 files changed

+116
-1
lines changed

res/css/_components.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
@import "./views/groups/_GroupUserSettings.scss";
6969
@import "./views/login/_InteractiveAuthEntryComponents.scss";
7070
@import "./views/login/_ServerConfig.scss";
71+
@import "./views/messages/_CreateEvent.scss";
7172
@import "./views/messages/_DateSeparator.scss";
7273
@import "./views/messages/_MEmoteBody.scss";
7374
@import "./views/messages/_MFileBody.scss";
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
Copyright 2018 New Vector Ltd
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
.mx_CreateEvent {
18+
background-color: $info-plinth-bg-color;
19+
padding-left: 20px;
20+
padding-right: 20px;
21+
padding-top: 10px;
22+
padding-bottom: 10px;
23+
}
24+
25+
.mx_CreateEvent_image {
26+
float: left;
27+
padding-right: 20px;
28+
width: 72px;
29+
height: 34px;
30+
}
31+
32+
.mx_CreateEvent_header {
33+
font-weight: bold;
34+
}
35+
36+
.mx_CreateEvent_link {
37+
}

res/img/room-continuation.svg

Lines changed: 6 additions & 0 deletions
Loading
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/*
2+
Copyright 2018 New Vector Ltd
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
import React from 'react';
18+
import PropTypes from 'prop-types';
19+
20+
import dis from '../../../dispatcher';
21+
import { makeEventPermalink } from '../../../matrix-to';
22+
import { _t } from '../../../languageHandler';
23+
24+
module.exports = React.createClass({
25+
displayName: 'RoomCreate',
26+
27+
propTypes: {
28+
/* the MatrixEvent to show */
29+
mxEvent: PropTypes.object.isRequired,
30+
},
31+
32+
_onLinkClicked: function(e) {
33+
e.preventDefault();
34+
35+
const predecessor = this.props.mxEvent.getContent()['predecessor'];
36+
37+
dis.dispatch({
38+
action: 'view_room',
39+
event_id: predecessor['event_id'],
40+
highlighted: true,
41+
room_id: predecessor['room_id'],
42+
});
43+
},
44+
45+
render: function() {
46+
const predecessor = this.props.mxEvent.getContent()['predecessor'];
47+
if (predecessor === undefined) {
48+
return <div />; // We should never have been instaniated in this case
49+
}
50+
return <div className="mx_CreateEvent">
51+
<img className="mx_CreateEvent_image" src="img/room-continuation.svg" />
52+
<div className="mx_CreateEvent_header">
53+
{_t("This room is a continuation of another conversation.")}
54+
</div>
55+
<a className="mx_CreateEvent_link"
56+
href={makeEventPermalink(predecessor['room_id'], predecessor['event_id'])}
57+
onClick={this._onLinkClicked}
58+
>
59+
{_t("Click here to see older messages.")}
60+
</a>
61+
</div>;
62+
},
63+
});

src/components/views/rooms/EventTile.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ const eventTileTypes = {
4747
};
4848

4949
const stateEventTileTypes = {
50+
'm.room.create': 'messages.RoomCreate',
5051
'm.room.member': 'messages.TextualEvent',
5152
'm.room.name': 'messages.TextualEvent',
5253
'm.room.avatar': 'messages.RoomAvatarEvent',
@@ -483,7 +484,7 @@ module.exports = withMatrixClient(React.createClass({
483484
const eventType = this.props.mxEvent.getType();
484485

485486
// Info messages are basically information about commands processed on a room
486-
const isInfoMessage = (eventType !== 'm.room.message' && eventType !== 'm.sticker');
487+
const isInfoMessage = (eventType !== 'm.room.message' && eventType !== 'm.sticker' && eventType != 'm.room.create');
487488

488489
const tileHandler = getHandlerTile(this.props.mxEvent);
489490
// This shouldn't happen: the caller should check we support this type
@@ -535,6 +536,9 @@ module.exports = withMatrixClient(React.createClass({
535536
if (this.props.tileShape === "notif") {
536537
avatarSize = 24;
537538
needsSenderProfile = true;
539+
} else if (tileHandler === 'messages.RoomCreate') {
540+
avatarSize = 0;
541+
needsSenderProfile = false;
538542
} else if (isInfoMessage) {
539543
// a small avatar, with no sender profile, for
540544
// joins/parts/etc
@@ -745,6 +749,8 @@ module.exports.haveTileForEvent = function(e) {
745749
if (handler === undefined) return false;
746750
if (handler === 'messages.TextualEvent') {
747751
return TextForEvent.textForEvent(e) !== '';
752+
} else if (handler === 'messages.RoomCreate') {
753+
return Boolean(e.getContent()['predecessor']);
748754
} else {
749755
return true;
750756
}

src/i18n/strings/en_EN.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,8 @@
607607
"%(senderDisplayName)s changed the avatar for %(roomName)s": "%(senderDisplayName)s changed the avatar for %(roomName)s",
608608
"%(senderDisplayName)s removed the room avatar.": "%(senderDisplayName)s removed the room avatar.",
609609
"%(senderDisplayName)s changed the room avatar to <img/>": "%(senderDisplayName)s changed the room avatar to <img/>",
610+
"This room is a continuation of another conversation.": "This room is a continuation of another conversation.",
611+
"Click here to see older messages.": "Click here to see older messages.",
610612
"Copied!": "Copied!",
611613
"Failed to copy": "Failed to copy",
612614
"Add an Integration": "Add an Integration",

0 commit comments

Comments
 (0)