From 458d71a4966fd4a72b42b6bbd0672becf501bc0f Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Thu, 7 Jan 2016 16:22:17 +0000 Subject: [PATCH] Attempt to peek into rooms we don't know about. Also: display an error dialog if we fail to join the room if you click Join Room. --- src/components/structures/RoomView.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js index 99d4c1aa49..0b19951735 100644 --- a/src/components/structures/RoomView.js +++ b/src/components/structures/RoomView.js @@ -97,6 +97,24 @@ module.exports = React.createClass({ this.forceUpdate(); } }); + // if this is an unknown room then we're in one of three states: + // - This is a room we can peek into (search engine) (we can /peek) + // - This is a room we can publicly join or were invited to. (we can /join) + // - This is a room we cannot join at all. (no action can help us) + // We can't try to /join because this may implicitly accept invites (!) + // We can /peek though. If it fails then we present the join UI. If it + // 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() { + // we don't need to do anything - JS SDK will emit Room events + // which will update the UI. + }, function(err) { + console.error("Failed to peek into room: %s", err); + }); + } + + }, componentWillUnmount: function() { @@ -422,6 +440,12 @@ module.exports = React.createClass({ joining: false, joinError: error }); + var msg = error.message ? error.message : JSON.stringify(error); + var ErrorDialog = sdk.getComponent("dialogs.ErrorDialog"); + Modal.createDialog(ErrorDialog, { + title: "Failed to join room", + description: msg + }); }); this.setState({ joining: true