From 4f14ead741ce620b0782fe1939c867716ed552da Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Sun, 10 Jan 2016 04:22:09 +0000 Subject: [PATCH 1/4] idiot - fix bind warnings --- src/components/views/rooms/RoomSettings.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/views/rooms/RoomSettings.js b/src/components/views/rooms/RoomSettings.js index 0864dc15c7..72d9a19bba 100644 --- a/src/components/views/rooms/RoomSettings.js +++ b/src/components/views/rooms/RoomSettings.js @@ -216,7 +216,7 @@ module.exports = React.createClass({ ./ } - var boundClick = self.onColorSchemeChanged.bind(this, i) + var boundClick = self.onColorSchemeChanged.bind(self, i) return (
Date: Tue, 12 Jan 2016 14:11:15 +0000 Subject: [PATCH 2/4] Add a RoomPreviewBar which asks if you'd like to join a peeked room --- src/component-index.js | 9 ++-- src/components/structures/RoomView.js | 28 ++++++++-- src/components/views/rooms/RoomPreviewBar.js | 56 ++++++++++++++++++++ 3 files changed, 85 insertions(+), 8 deletions(-) create mode 100644 src/components/views/rooms/RoomPreviewBar.js diff --git a/src/component-index.js b/src/component-index.js index 0c08d70b73..cef1b093a4 100644 --- a/src/component-index.js +++ b/src/component-index.js @@ -23,14 +23,14 @@ limitations under the License. module.exports.components = {}; module.exports.components['structures.CreateRoom'] = require('./components/structures/CreateRoom'); +module.exports.components['structures.login.Login'] = require('./components/structures/login/Login'); +module.exports.components['structures.login.PostRegistration'] = require('./components/structures/login/PostRegistration'); +module.exports.components['structures.login.Registration'] = require('./components/structures/login/Registration'); module.exports.components['structures.MatrixChat'] = require('./components/structures/MatrixChat'); module.exports.components['structures.RoomView'] = require('./components/structures/RoomView'); module.exports.components['structures.ScrollPanel'] = require('./components/structures/ScrollPanel'); module.exports.components['structures.UploadBar'] = require('./components/structures/UploadBar'); module.exports.components['structures.UserSettings'] = require('./components/structures/UserSettings'); -module.exports.components['structures.login.Login'] = require('./components/structures/login/Login'); -module.exports.components['structures.login.PostRegistration'] = require('./components/structures/login/PostRegistration'); -module.exports.components['structures.login.Registration'] = require('./components/structures/login/Registration'); module.exports.components['views.avatars.MemberAvatar'] = require('./components/views/avatars/MemberAvatar'); module.exports.components['views.avatars.RoomAvatar'] = require('./components/views/avatars/RoomAvatar'); module.exports.components['views.create_room.CreateRoomButton'] = require('./components/views/create_room/CreateRoomButton'); @@ -51,10 +51,10 @@ module.exports.components['views.login.LoginHeader'] = require('./components/vie module.exports.components['views.login.PasswordLogin'] = require('./components/views/login/PasswordLogin'); module.exports.components['views.login.RegistrationForm'] = require('./components/views/login/RegistrationForm'); module.exports.components['views.login.ServerConfig'] = require('./components/views/login/ServerConfig'); +module.exports.components['views.messages.MessageEvent'] = require('./components/views/messages/MessageEvent'); module.exports.components['views.messages.MFileBody'] = require('./components/views/messages/MFileBody'); module.exports.components['views.messages.MImageBody'] = require('./components/views/messages/MImageBody'); module.exports.components['views.messages.MVideoBody'] = require('./components/views/messages/MVideoBody'); -module.exports.components['views.messages.MessageEvent'] = require('./components/views/messages/MessageEvent'); module.exports.components['views.messages.TextualBody'] = require('./components/views/messages/TextualBody'); module.exports.components['views.messages.TextualEvent'] = require('./components/views/messages/TextualEvent'); module.exports.components['views.messages.UnknownBody'] = require('./components/views/messages/UnknownBody'); @@ -65,6 +65,7 @@ module.exports.components['views.rooms.MemberTile'] = require('./components/view module.exports.components['views.rooms.MessageComposer'] = require('./components/views/rooms/MessageComposer'); module.exports.components['views.rooms.RoomHeader'] = require('./components/views/rooms/RoomHeader'); module.exports.components['views.rooms.RoomList'] = require('./components/views/rooms/RoomList'); +module.exports.components['views.rooms.RoomPreviewBar'] = require('./components/views/rooms/RoomPreviewBar'); module.exports.components['views.rooms.RoomSettings'] = require('./components/views/rooms/RoomSettings'); module.exports.components['views.rooms.RoomTile'] = require('./components/views/rooms/RoomTile'); module.exports.components['views.rooms.SearchResultTile'] = require('./components/views/rooms/SearchResultTile'); diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js index c622a7d769..7a729a4436 100644 --- a/src/components/structures/RoomView.js +++ b/src/components/structures/RoomView.js @@ -74,6 +74,7 @@ module.exports = React.createClass({ syncState: MatrixClientPeg.get().getSyncState(), hasUnsentMessages: this._hasUnsentMessages(room), callState: null, + guestsCanJoin: false } }, @@ -106,15 +107,27 @@ module.exports = React.createClass({ // succeeds then great, show the preview (but we still may be able to /join!). if (!this.state.room) { console.log("Attempting to peek into room %s", this.props.roomId); - MatrixClientPeg.get().peekInRoom(this.props.roomId).done(function() { + MatrixClientPeg.get().peekInRoom(this.props.roomId).done(() => { // we don't need to do anything - JS SDK will emit Room events - // which will update the UI. + // which will update the UI. We *do* however need to know if we + // can join the room so we can fiddle with the UI appropriately. + var peekedRoom = MatrixClientPeg.get().getRoom(this.props.roomId); + if (!peekedRoom) { + return; + } + var guestAccessEvent = peekedRoom.currentState.getStateEvents("m.room.guest_access", ""); + if (!guestAccessEvent) { + return; + } + if (guestAccessEvent.getContent().guest_access === "can_join") { + this.setState({ + guestsCanJoin: true + }); + } }, function(err) { console.error("Failed to peek into room: %s", err); }); } - - }, componentWillUnmount: function() { @@ -1132,6 +1145,7 @@ module.exports = React.createClass({ var SearchBar = sdk.getComponent("rooms.SearchBar"); var ScrollPanel = sdk.getComponent("structures.ScrollPanel"); var TintableSvg = sdk.getComponent("elements.TintableSvg"); + var RoomPreviewBar = sdk.getComponent("rooms.RoomPreviewBar"); if (!this.state.room) { if (this.props.roomId) { @@ -1282,6 +1296,12 @@ module.exports = React.createClass({ else if (this.state.searching) { aux = ; } + else if (this.state.guestsCanJoin && MatrixClientPeg.get().isGuest() && + (!myMember || myMember.membership !== "join")) { + aux = ( + + ); + } var conferenceCallNotification = null; if (this.state.displayConfCallNotification) { diff --git a/src/components/views/rooms/RoomPreviewBar.js b/src/components/views/rooms/RoomPreviewBar.js new file mode 100644 index 0000000000..2f12c4c8e2 --- /dev/null +++ b/src/components/views/rooms/RoomPreviewBar.js @@ -0,0 +1,56 @@ +/* +Copyright 2015, 2016 OpenMarket 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. +*/ + +'use strict'; + +var React = require('react'); + +module.exports = React.createClass({ + displayName: 'RoomPreviewBar', + + propTypes: { + onJoinClick: React.PropTypes.func, + canJoin: React.PropTypes.bool + }, + + getDefaultProps: function() { + return { + onJoinClick: function() {}, + canJoin: false + }; + }, + + render: function() { + var joinBlock; + + if (this.props.canJoin) { + joinBlock = ( +
+ Would you like to join this room? +
+ ); + } + + return ( +
+
+ This is a preview of this room. Room interactions have been disabled. +
+ {joinBlock} +
+ ); + } +}); From 3934b42ac88e975823b9bed5b3e46239d67ba1b4 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Wed, 13 Jan 2016 13:01:00 +0000 Subject: [PATCH 3/4] s/m.room.color_scheme/org.matrix.room.color_scheme/g # to make kegan happier --- src/SlashCommands.js | 2 +- src/components/structures/MatrixChat.js | 2 +- src/components/structures/RoomView.js | 6 +++--- src/components/views/rooms/RoomSettings.js | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/SlashCommands.js b/src/SlashCommands.js index 35216aa403..1dd7ecb08f 100644 --- a/src/SlashCommands.js +++ b/src/SlashCommands.js @@ -57,7 +57,7 @@ var commands = { } return success( MatrixClientPeg.get().setRoomAccountData( - room_id, "m.room.color_scheme", colorScheme + room_id, "org.matrix.room.color_scheme", colorScheme ) ); } diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js index 56885ce499..ef77787035 100644 --- a/src/components/structures/MatrixChat.js +++ b/src/components/structures/MatrixChat.js @@ -360,7 +360,7 @@ module.exports = React.createClass({ var theAlias = MatrixTools.getCanonicalAliasForRoom(room); if (theAlias) presentedId = theAlias; - var color_scheme_event = room.getAccountData("m.room.color_scheme"); + var color_scheme_event = room.getAccountData("org.matrix.room.color_scheme"); var color_scheme = {}; if (color_scheme_event) { color_scheme = color_scheme_event.getContent(); diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js index 08dfe75584..625f4da98b 100644 --- a/src/components/structures/RoomView.js +++ b/src/components/structures/RoomView.js @@ -244,7 +244,7 @@ module.exports = React.createClass({ var room = MatrixClientPeg.get().getRoom(this.props.roomId); if (!room) return; - var color_scheme_event = room.getAccountData("m.room.color_scheme"); + var color_scheme_event = room.getAccountData("org.matrix.room.color_scheme"); var color_scheme = {}; if (color_scheme_event) { color_scheme = color_scheme_event.getContent(); @@ -255,7 +255,7 @@ module.exports = React.createClass({ onRoomAccountData: function(room, event) { if (room.roomId == this.props.roomId) { - if (event.getType === "m.room.color_scheme") { + if (event.getType === "org.matrix.room.color_scheme") { var color_scheme = event.getContent(); // XXX: we should validate the event Tinter.tint(color_scheme.primary_color, color_scheme.secondary_color); @@ -810,7 +810,7 @@ module.exports = React.createClass({ if (new_color_scheme) { deferreds.push( MatrixClientPeg.get().setRoomAccountData( - this.state.room.roomId, "m.room.color_scheme", new_color_scheme + this.state.room.roomId, "org.matrix.room.color_scheme", new_color_scheme ) ); } diff --git a/src/components/views/rooms/RoomSettings.js b/src/components/views/rooms/RoomSettings.js index 72d9a19bba..74ffa7f5a7 100644 --- a/src/components/views/rooms/RoomSettings.js +++ b/src/components/views/rooms/RoomSettings.js @@ -43,7 +43,7 @@ module.exports = React.createClass({ getInitialState: function() { // work out the initial color index var room_color_index = undefined; - var color_scheme_event = this.props.room.getAccountData("m.room.color_scheme"); + var color_scheme_event = this.props.room.getAccountData("org.matrix.room.color_scheme"); if (color_scheme_event) { var color_scheme = color_scheme_event.getContent(); if (color_scheme.primary_color) color_scheme.primary_color = color_scheme.primary_color.toLowerCase(); From 11025e2ba947f5cdc89d74e561eec17f990d1d82 Mon Sep 17 00:00:00 2001 From: David Baker Date: Wed, 13 Jan 2016 15:18:21 +0000 Subject: [PATCH 4/4] Make read marker ghost same width as normal one. --- src/components/structures/RoomView.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js index ddde9c2645..8e193b25ab 100644 --- a/src/components/structures/RoomView.js +++ b/src/components/structures/RoomView.js @@ -839,7 +839,7 @@ module.exports = React.createClass({ // is the last element or not, because we only decide as we're going along. if (readMarkerIndex === undefined && ghostIndex && ghostIndex <= ret.length) { var hr; - hr = (