diff --git a/src/components/structures/RoomDirectory.js b/src/components/structures/RoomDirectory.js index 0f90a0ac..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", @@ -87,13 +97,34 @@ 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; + var shouldPeek = false; + + if (rooms[i].world_readable) { + guestRead = ( + + ); + if (MatrixClientPeg.get().isGuest() && !rooms[i].guest_can_join) { + shouldPeek = true; + } + } + if (rooms[i].guest_can_join) { + guestJoin = ( + + ); + } + // rows.unshift(
-