From 1a8a4728cd6929657efa9539b7ed007f54546054 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Thu, 7 Jan 2016 14:43:12 +0000 Subject: [PATCH 1/2] Enable guest access. Show r/w icons on room directory. --- src/components/structures/RoomDirectory.js | 19 ++++++++++++++++++- src/vector/index.js | 3 ++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/components/structures/RoomDirectory.js b/src/components/structures/RoomDirectory.js index 0f90a0ac..80962af7 100644 --- a/src/components/structures/RoomDirectory.js +++ b/src/components/structures/RoomDirectory.js @@ -87,13 +87,30 @@ module.exports = React.createClass({ }); var rows = []; var self = this; + var guestRead, guestJoin; for (var i = 0; i < rooms.length; i++) { var name = rooms[i].name || rooms[i].aliases[0]; + guestRead = null; + guestJoin = null; + + if (rooms[i].world_readable) { + guestRead = ( + World Readable + ); + } + if (rooms[i].guest_can_join) { + guestJoin = ( + Guests can join + ); + } + // rows.unshift( - { name } + { name } {guestRead} {guestJoin} { rooms[i].aliases[0] } { rooms[i].num_joined_members } diff --git a/src/vector/index.js b/src/vector/index.js index 4c79f11d..13fcd4c6 100644 --- a/src/vector/index.js +++ b/src/vector/index.js @@ -154,7 +154,8 @@ function loadApp() { registrationUrl={makeRegistrationUrl()} ConferenceHandler={VectorConferenceHandler} config={configJson} - startingQueryParams={parseQsFromFragment(window.location)} />, + startingQueryParams={parseQsFromFragment(window.location)} + enableGuest={true} />, document.getElementById('matrixchat') ); } From a369c862a06496cd1ea624463161d37e0c40e3ce Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Thu, 7 Jan 2016 14:57:26 +0000 Subject: [PATCH 2/2] Hit MatrixClient.peekInRoom on rooms we can only peek into. --- src/components/structures/RoomDirectory.js | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/components/structures/RoomDirectory.js b/src/components/structures/RoomDirectory.js index 80962af7..ea2a7237 100644 --- a/src/components/structures/RoomDirectory.js +++ b/src/components/structures/RoomDirectory.js @@ -56,17 +56,27 @@ module.exports = React.createClass({ }); }, - joinRoom: function(roomId) { + joinRoom: function(roomId, shouldPeek) { var self = this; self.setState({ loading: true }); - // XXX: check that JS SDK suppresses duplicate attempts to join the same room - MatrixClientPeg.get().joinRoom(roomId).done(function() { + + var joinOrPeekPromise; + + if (shouldPeek) { + joinOrPeekPromise = MatrixClientPeg.get().peekInRoom(roomId); + } + else { + joinOrPeekPromise = MatrixClientPeg.get().joinRoom(roomId); + } + + joinOrPeekPromise.done(function() { dis.dispatch({ action: 'view_room', room_id: roomId }); }, function(err) { console.error("Failed to join room: %s", JSON.stringify(err)); + console.error(err); var ErrorDialog = sdk.getComponent("dialogs.ErrorDialog"); Modal.createDialog(ErrorDialog, { title: "Failed to join room", @@ -92,12 +102,16 @@ module.exports = React.createClass({ var name = rooms[i].name || rooms[i].aliases[0]; guestRead = null; guestJoin = null; + var shouldPeek = false; if (rooms[i].world_readable) { guestRead = ( World Readable ); + if (MatrixClientPeg.get().isGuest() && !rooms[i].guest_can_join) { + shouldPeek = true; + } } if (rooms[i].guest_can_join) { guestJoin = ( @@ -109,7 +123,7 @@ module.exports = React.createClass({ // rows.unshift( - + { name } {guestRead} {guestJoin} { rooms[i].aliases[0] } { rooms[i].num_joined_members }