From ab10b5493bf4e536741e3c68155e92867bfbbcd5 Mon Sep 17 00:00:00 2001 From: David Baker Date: Mon, 20 Aug 2018 16:20:59 +0100 Subject: [PATCH 1/4] Support room creation events For https://github.com/vector-im/riot-web/issues/7164 --- res/css/_components.scss | 1 + res/css/views/messages/_CreateEvent.scss | 35 +++++++++++ src/components/views/messages/RoomCreate.js | 64 +++++++++++++++++++++ src/components/views/rooms/EventTile.js | 8 ++- src/i18n/strings/en_EN.json | 20 ++----- 5 files changed, 113 insertions(+), 15 deletions(-) create mode 100644 res/css/views/messages/_CreateEvent.scss create mode 100644 src/components/views/messages/RoomCreate.js diff --git a/res/css/_components.scss b/res/css/_components.scss index 173939e143..13fefd5885 100644 --- a/res/css/_components.scss +++ b/res/css/_components.scss @@ -67,6 +67,7 @@ @import "./views/groups/_GroupUserSettings.scss"; @import "./views/login/_InteractiveAuthEntryComponents.scss"; @import "./views/login/_ServerConfig.scss"; +@import "./views/messages/_CreateEvent.scss"; @import "./views/messages/_DateSeparator.scss"; @import "./views/messages/_MEmoteBody.scss"; @import "./views/messages/_MFileBody.scss"; diff --git a/res/css/views/messages/_CreateEvent.scss b/res/css/views/messages/_CreateEvent.scss new file mode 100644 index 0000000000..47de2c9753 --- /dev/null +++ b/res/css/views/messages/_CreateEvent.scss @@ -0,0 +1,35 @@ +/* +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. +*/ + +.mx_CreateEvent { + background-color: $info-plinth-bg-color; + padding-left: 20px; + padding-right: 20px; + padding-top: 10px; + padding-bottom: 10px; +} + +.mx_CreateEvent_image { + float: left; + padding-right: 20px; +} + +.mx_CreateEvent_header { + font-weight: bold; +} + +.mx_CreateEvent_link { +} diff --git a/src/components/views/messages/RoomCreate.js b/src/components/views/messages/RoomCreate.js new file mode 100644 index 0000000000..8159741ae1 --- /dev/null +++ b/src/components/views/messages/RoomCreate.js @@ -0,0 +1,64 @@ +/* +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'; + +import dis from '../../../dispatcher'; +import sdk from '../../../index'; +import { makeEventPermalink } from '../../../matrix-to'; +import { _t } from '../../../languageHandler'; + +module.exports = React.createClass({ + 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
; // We should never have been instaniated in this case + } + return
+ +
+ {_t("This room is a continuation of another conversation.")} +
+ + {_t("Click here to see older messages.")} + +
; + }, +}); diff --git a/src/components/views/rooms/EventTile.js b/src/components/views/rooms/EventTile.js index 7e73c01330..8dcc2139a7 100644 --- a/src/components/views/rooms/EventTile.js +++ b/src/components/views/rooms/EventTile.js @@ -47,6 +47,7 @@ const eventTileTypes = { }; const stateEventTileTypes = { + 'm.room.create': 'messages.RoomCreate', 'm.room.member': 'messages.TextualEvent', 'm.room.name': 'messages.TextualEvent', 'm.room.avatar': 'messages.RoomAvatarEvent', @@ -483,7 +484,7 @@ module.exports = withMatrixClient(React.createClass({ const eventType = this.props.mxEvent.getType(); // Info messages are basically information about commands processed on a room - const isInfoMessage = (eventType !== 'm.room.message' && eventType !== 'm.sticker'); + const isInfoMessage = (eventType !== 'm.room.message' && eventType !== 'm.sticker' && eventType != 'm.room.create'); const tileHandler = getHandlerTile(this.props.mxEvent); // This shouldn't happen: the caller should check we support this type @@ -535,6 +536,9 @@ module.exports = withMatrixClient(React.createClass({ if (this.props.tileShape === "notif") { avatarSize = 24; needsSenderProfile = true; + } else if (tileHandler === 'messages.RoomCreate') { + avatarSize = 0; + needsSenderProfile = false; } else if (isInfoMessage) { // a small avatar, with no sender profile, for // joins/parts/etc @@ -745,6 +749,8 @@ module.exports.haveTileForEvent = function(e) { if (handler === undefined) return false; if (handler === 'messages.TextualEvent') { return TextForEvent.textForEvent(e) !== ''; + } else if (handler === 'messages.RoomCreate') { + return Boolean(e.getContent()['predecessor']); } else { return true; } diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index fcc9bcc8be..db2537307d 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -205,6 +205,7 @@ "Authentication check failed: incorrect password?": "Authentication check failed: incorrect password?", "Failed to join room": "Failed to join room", "Message Pinning": "Message Pinning", + "Increase performance by only loading room members on first view": "Increase performance by only loading room members on first view", "Disable Emoji suggestions while typing": "Disable Emoji suggestions while typing", "Use compact timeline layout": "Use compact timeline layout", "Hide removed messages": "Hide removed messages", @@ -543,10 +544,6 @@ "Internal room ID: ": "Internal room ID: ", "Room version number: ": "Room version number: ", "Add a topic": "Add a topic", - "There is a known vulnerability affecting this room.": "There is a known vulnerability affecting this room.", - "This room version is vulnerable to malicious modification of room state.": "This room version is vulnerable to malicious modification of room state.", - "Click here to upgrade to the latest room version and ensure room integrity is protected.": "Click here to upgrade to the latest room version and ensure room integrity is protected.", - "Only room administrators will see this warning": "Only room administrators will see this warning", "Search…": "Search…", "This Room": "This Room", "All Rooms": "All Rooms", @@ -603,6 +600,8 @@ "%(senderDisplayName)s changed the avatar for %(roomName)s": "%(senderDisplayName)s changed the avatar for %(roomName)s", "%(senderDisplayName)s removed the room avatar.": "%(senderDisplayName)s removed the room avatar.", "%(senderDisplayName)s changed the room avatar to ": "%(senderDisplayName)s changed the room avatar to ", + "This room is a continuation of another conversation.": "This room is a continuation of another conversation.", + "Click here to see older messages.": "Click here to see older messages.", "Copied!": "Copied!", "Failed to copy": "Failed to copy", "Add an Integration": "Add an Integration", @@ -865,12 +864,6 @@ "Ignore request": "Ignore request", "Loading device info...": "Loading device info...", "Encryption key request": "Encryption key request", - "Upgrade Room Version": "Upgrade Room Version", - "Upgrading this room requires closing down the current instance of the room and creating a new room it its place. To give room members the best possible experience, we will:": "Upgrading this room requires closing down the current instance of the room and creating a new room it its place. To give room members the best possible experience, we will:", - "Create a new room with the same name, description and avatar": "Create a new room with the same name, description and avatar", - "Update any local room aliases to point to the new room": "Update any local room aliases to point to the new room", - "Stop users from speaking in the old version of the room, and post a message advising users to move to the new room": "Stop users from speaking in the old version of the room, and post a message advising users to move to the new room", - "Put a link back to the old room at the start of the new room so people can see old messages": "Put a link back to the old room at the start of the new room so people can see old messages", "Sign out": "Sign out", "Log out and remove encryption keys?": "Log out and remove encryption keys?", "Clear Storage and Sign Out": "Clear Storage and Sign Out", @@ -1121,6 +1114,8 @@ "Labs": "Labs", "These are experimental features that may break in unexpected ways": "These are experimental features that may break in unexpected ways", "Use with caution": "Use with caution", + "Lazy loading members not supported": "Lazy loading members not supported", + "Lazy loading is not supported by your current homeserver.": "Lazy loading is not supported by your current homeserver.", "Deactivate my account": "Deactivate my account", "Clear Cache": "Clear Cache", "Clear Cache and Reload": "Clear Cache and Reload", @@ -1231,8 +1226,5 @@ "Import": "Import", "Failed to set direct chat tag": "Failed to set direct chat tag", "Failed to remove tag %(tagName)s from room": "Failed to remove tag %(tagName)s from room", - "Failed to add tag %(tagName)s to room": "Failed to add tag %(tagName)s to room", - "Increase performance by only loading room members on first view": "Increase performance by only loading room members on first view", - "Lazy loading members not supported": "Lazy load members not supported", - "Lazy loading is not supported by your current homeserver.": "Lazy loading is not supported by your current homeserver." + "Failed to add tag %(tagName)s to room": "Failed to add tag %(tagName)s to room" } From c4235ca20a713c5707ab0a56ee1ec487011c8076 Mon Sep 17 00:00:00 2001 From: David Baker Date: Tue, 21 Aug 2018 17:50:59 +0100 Subject: [PATCH 2/4] Add the image --- res/img/room-continuation.svg | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 res/img/room-continuation.svg diff --git a/res/img/room-continuation.svg b/res/img/room-continuation.svg new file mode 100644 index 0000000000..dc7e15462a --- /dev/null +++ b/res/img/room-continuation.svg @@ -0,0 +1,6 @@ + + + + + + From cd4b520574d8c97104fc70821f45927a45fad2c6 Mon Sep 17 00:00:00 2001 From: David Baker Date: Tue, 21 Aug 2018 17:52:13 +0100 Subject: [PATCH 3/4] Add image dimensions To avoid popping when the image loads & make sure the SVG appears the right size --- res/css/views/messages/_CreateEvent.scss | 2 ++ 1 file changed, 2 insertions(+) diff --git a/res/css/views/messages/_CreateEvent.scss b/res/css/views/messages/_CreateEvent.scss index 47de2c9753..c095fc26af 100644 --- a/res/css/views/messages/_CreateEvent.scss +++ b/res/css/views/messages/_CreateEvent.scss @@ -25,6 +25,8 @@ limitations under the License. .mx_CreateEvent_image { float: left; padding-right: 20px; + width: 72px; + height: 34px; } .mx_CreateEvent_header { From 6cbe4144d4c648f34e1ff01ce0e678d91536eb13 Mon Sep 17 00:00:00 2001 From: David Baker Date: Wed, 29 Aug 2018 18:28:16 +0100 Subject: [PATCH 4/4] unused import --- src/components/views/messages/RoomCreate.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/views/messages/RoomCreate.js b/src/components/views/messages/RoomCreate.js index 8159741ae1..0bb832f8ea 100644 --- a/src/components/views/messages/RoomCreate.js +++ b/src/components/views/messages/RoomCreate.js @@ -18,7 +18,6 @@ import React from 'react'; import PropTypes from 'prop-types'; import dis from '../../../dispatcher'; -import sdk from '../../../index'; import { makeEventPermalink } from '../../../matrix-to'; import { _t } from '../../../languageHandler';