From 1cabe2ec37d93a4a1eccd1a702e11c5da532ef6e Mon Sep 17 00:00:00 2001 From: David Baker Date: Tue, 2 Feb 2016 15:50:15 +0000 Subject: [PATCH 1/2] Don't auto join rooms: always 'autoPeek' (ie. see if we can peek, otherwise offer to join) --- src/components/structures/MatrixChat.js | 5 ----- src/components/structures/RoomView.js | 8 +++++++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js index 6050076d12..5c2fd21a39 100644 --- a/src/components/structures/MatrixChat.js +++ b/src/components/structures/MatrixChat.js @@ -66,7 +66,6 @@ module.exports = React.createClass({ collapse_rhs: false, ready: false, width: 10000, - autoPeek: true, // by default, we peek into rooms when we try to join them }; if (s.logged_in) { if (MatrixClientPeg.get().getRooms().length) { @@ -317,9 +316,6 @@ module.exports = React.createClass({ }); break; case 'view_room': - // by default we autoPeek rooms, unless we were called explicitly with - // autoPeek=false by something like RoomDirectory who has already peeked - this.setState({ autoPeek : payload.auto_peek === false ? false : true }); this._viewRoom(payload.room_id, payload.show_settings); break; case 'view_prev_room': @@ -843,7 +839,6 @@ module.exports = React.createClass({ ); diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js index e2ed8231ef..361595d003 100644 --- a/src/components/structures/RoomView.js +++ b/src/components/structures/RoomView.js @@ -59,7 +59,13 @@ module.exports = React.createClass({ propTypes: { ConferenceHandler: React.PropTypes.any, roomId: React.PropTypes.string, - autoPeek: React.PropTypes.bool, // should we try to peek the room on mount, or has whoever invoked us already initiated a peek? + autoPeek: React.PropTypes.bool, // Now unused, left here temporarily to avoid merge conflicts with @richvdh's branch. + }, + + getDefaultProps: function() { + return { + autoPeek: true, + } }, /* properties in RoomView objects include: From b0f0d5f6d0b8782c3dafedf758634c5cee954391 Mon Sep 17 00:00:00 2001 From: David Baker Date: Tue, 2 Feb 2016 16:34:41 +0000 Subject: [PATCH 2/2] Null check room because those events will be emitted before the room is stored. --- src/components/structures/RoomView.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js index 361595d003..b461ef25a5 100644 --- a/src/components/structures/RoomView.js +++ b/src/components/structures/RoomView.js @@ -385,6 +385,7 @@ module.exports = React.createClass({ this._updateTabCompleteList(this.state.room); var room = MatrixClientPeg.get().getRoom(this.props.roomId); + if (!room) return; var me = MatrixClientPeg.get().credentials.userId; if (this.state.joining && room.hasMembershipState(me, "join")) { this.setState({