From 0bc4659fe03e580f5eacf7b26fc730d87fb75920 Mon Sep 17 00:00:00 2001
From: David Baker <dave@matrix.org>
Date: Thu, 24 Nov 2016 12:33:31 +0000
Subject: [PATCH 1/3] Fix crash on logging in

If you arrived at the page via a link to a room.

Fixes https://github.com/vector-im/vector-web/issues/2634
---
 src/components/structures/MatrixChat.js | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js
index 945088106b..e632d9a4c5 100644
--- a/src/components/structures/MatrixChat.js
+++ b/src/components/structures/MatrixChat.js
@@ -75,6 +75,9 @@ module.exports = React.createClass({
             loading: true,
             screen: undefined,
 
+            // What the LoggedInView would be showing if visible
+            page_type: PageTypes.RoomDirectory,
+
             // If we are viewing a room by alias, this contains the alias
             currentRoomAlias: null,
 
@@ -235,6 +238,7 @@ module.exports = React.createClass({
     setStateForNewScreen: function(state) {
         const newState = {
             screen: undefined,
+            page_type: PageTypes.RoomDirectory,
             currentRoomAlias: null,
             currentRoomId: null,
             viewUserId: null,

From 00693936506c021c1df98ca033d11d9513e79628 Mon Sep 17 00:00:00 2001
From: David Baker <dave@matrix.org>
Date: Thu, 24 Nov 2016 13:28:51 +0000
Subject: [PATCH 2/3] Go back to same room after logging in

---
 src/components/structures/MatrixChat.js | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js
index e632d9a4c5..4d3ddc5634 100644
--- a/src/components/structures/MatrixChat.js
+++ b/src/components/structures/MatrixChat.js
@@ -238,9 +238,6 @@ module.exports = React.createClass({
     setStateForNewScreen: function(state) {
         const newState = {
             screen: undefined,
-            page_type: PageTypes.RoomDirectory,
-            currentRoomAlias: null,
-            currentRoomId: null,
             viewUserId: null,
             logged_in: false,
             ready: false,

From 2aba646acd706608778d0e2c04eaf4f86ca6c6fa Mon Sep 17 00:00:00 2001
From: David Baker <dave@matrix.org>
Date: Thu, 24 Nov 2016 14:58:37 +0000
Subject: [PATCH 3/3] Clear room alias etc. on logout

---
 src/components/structures/MatrixChat.js | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js
index 4d3ddc5634..7fa7c9f152 100644
--- a/src/components/structures/MatrixChat.js
+++ b/src/components/structures/MatrixChat.js
@@ -598,6 +598,9 @@ module.exports = React.createClass({
             ready: false,
             collapse_lhs: false,
             collapse_rhs: false,
+            currentRoomAlias: null,
+            currentRoomId: null,
+            page_type: PageTypes.RoomDirectory,
         });
     },